N
Nuxt10mo ago
CODY

How to get correct type of $attrs/useAttrs?

No description
1 Reply
IsraelOrtuno
IsraelOrtuno10mo ago
Not sure you can even do that, attributes can literally be anything. Maybe a better approach is to use a computed property where you check that these properties actually exist:
const attrs = useAttrs()

const computedStyles = computed(() => {
const style = attrs.style || {}

return {
marginTop: -3,
width: 'auto',
...style
}
});
const attrs = useAttrs()

const computedStyles = computed(() => {
const style = attrs.style || {}

return {
marginTop: -3,
width: 'auto',
...style
}
});
Want results from more Discord servers?
Add your server