// 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>
// 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>