Answer the question
In order to leave comments, you need to log in
Passing css classes to a component - display these classes not on the root element, on the child?
Hello.
Imagine there is a FormButton component - a regular html button, but not just a button, but wrapped in some kind of container, like:<input />
<div class="col-12">
<input />
</div>
<FormButton class="btn-danger" />
Answer the question
In order to leave comments, you need to log in
Make the component functional, where classes (as well as other attributes) do not automatically cling to the root, you can independently choose who should add them:
functional: true,
render(h, ctx) {
return h('div', {
class: 'col-12',
}, [
h('input', {
class: [ ctx.data.class, ctx.data.staticClass ],
}),
]);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question