๐ 3 Variable Problems
SuperService opened this issue ยท comments
๐ nice to again meet you ๐
โFirst Problem
const to = toRef(props, 'to') in Anchor.vue
const to = props.to in Button.vue
๐ what is best way to get value from props?
โSecond Problem
const props = defineProps({
type: {
type: String,
default: 'primary'
},
title: {
type: String,
default: undefined
},
text: {
type: String,
default: undefined
}
}) in Alert.vue
๐why do you use default = undefined insteadof string empty?
โThird Problem
CardTitle.vue
why do you use tag with {{ text }}?
I checked that it don't need
right?
1
for the first problem you can find it directly in the documentation
here
https://vuejs.org/api/reactivity-utilities.html#toref
2
second problem,
i made the default undefined so that when i want to fetch it, then i want to check if the props are filled just by using
if (!prop.title) console.log('prop title not set')
than I have to type
if (prop.title === '') console.log('prop title not set')
3
third problem, it's related to vue component, you can check it in the docs for more details.
basically I made 2 options, namely filling the CardTitle through the property
<CardTitle text="This is title" />
or use slots:
<CardTitle>
<h1>This is title</h1>
</CardTitle>
When filling using Slots, then {{ text }} will be considered as non-existent. so it just gives the choice to the user.
Thanks for your kindly solution ๐