0

When I use a prop in SFC the prop shows empty, or as you prefer it does not show.

I have an ActionButton.vue file:

<script setup> defineProps({ actionButtonOne: { type: String } }) </script> <template> <button type="button">{{ actionButtonOne }}</button> </template> 

And I am importing it to CardElement.vue:

<script setup> import ActionButton from './ActionButton.vue' defineProps({ singleItem: { type: String } }) </script> <template> <ul> <li>{{ singleItem }} <ActionButton>Remove</ActionButton></li> </ul> </template> 

But when I look in the browser, my Buttons are empty, just a rectangle without "Remove" description. Why is this and what can I do to fix it?

0

1 Answer 1

1

You can directly use slot to pass content or pass a value for the defined prop :

<script setup> import ActionButton from './ActionButton.vue' defineProps({ singleItem: { type: String } }) </script> <template> <ul> <li>{{ singleItem }} <ActionButton action-button-one="Remove" ></ActionButton></li> </ul> </template> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.