Vue · Junior · Question 33 of 75

What happens to attributes like class passed to a component that doesn't declare them as props?

<MyButton class="large" data-test="save" />

Explanation

Fallthrough attributes (including listeners like @click) are applied to the single root element; class and style are merged. Use inheritAttrs: false with v-bind="$attrs" to move them elsewhere.

Further reading

Problem with a question

Vue · Junior · question 33

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz