Techno1Monkey
Techno1Monkey
NNuxt
Created by Techno1Monkey on 6/18/2024 in #❓・help
i18next acting weird
See the video below. The languages are not loaded into the input field untill I change the language, then it will update..
4 replies
NNuxt
Created by Techno1Monkey on 4/8/2024 in #❓・help
Regex not working from prop
When I pass format as a prop it doesn't work. But when I pass it as a local value with the exact same regex is do work:
// This doesn't work
// props.format = '^(?=.*\\d).{8,}$'

<script setup>
const props = defineProps(['format', 'message', 'value']);

function checkValid(){
if (!props.format || !props.value) {
return true;
}

const regex = new RegExp(props.format);
console.log(regex.test(props.value))
return regex.test(props.value);
}
</script>
// This doesn't work
// props.format = '^(?=.*\\d).{8,}$'

<script setup>
const props = defineProps(['format', 'message', 'value']);

function checkValid(){
if (!props.format || !props.value) {
return true;
}

const regex = new RegExp(props.format);
console.log(regex.test(props.value))
return regex.test(props.value);
}
</script>
// This do work

<script setup>
const props = defineProps(['format', 'message', 'value']);

const example = '^(?=.*\\d).{8,}$';

function checkValid(){
if (!props.format || !props.value) {
return true;
}

const regex = new RegExp(example);
console.log(regex.test(props.value))
return regex.test(props.value);
}
</script>
// This do work

<script setup>
const props = defineProps(['format', 'message', 'value']);

const example = '^(?=.*\\d).{8,}$';

function checkValid(){
if (!props.format || !props.value) {
return true;
}

const regex = new RegExp(example);
console.log(regex.test(props.value))
return regex.test(props.value);
}
</script>
5 replies
NNuxt
Created by Techno1Monkey on 4/8/2024 in #❓・help
[RESOLVED] Component children
I'm new to Vue/Nuxt.js and coming from React. I'm trying to define children in a component so I can do things like this, but is this a thing:
// alert.js

<template>
<div class="bg-red-200 text-red-600 p-2 rounded">
{{ children }}
</div>
</template>

<script setup>
const props = defineProps(['children'])
</script>
// alert.js

<template>
<div class="bg-red-200 text-red-600 p-2 rounded">
{{ children }}
</div>
</template>

<script setup>
const props = defineProps(['children'])
</script>
// login.vue

<template>
<alert>
<p class="font-bold">
Example
</div>
</alert>
</template>
// login.vue

<template>
<alert>
<p class="font-bold">
Example
</div>
</alert>
</template>
3 replies