I've a dynamic view:
<div id="myview">
<div :is="currentComponent"></div>
</div>
with an associated Vue instance:
new Vue ({
data: function () {
return {
currentComponent: 'myComponent',
}
},
}).$mount('#myview');
This allows me to change my component dynamically.
In my case, I have three different components: myComponent
, myComponent1
, and myComponent2
. And I switch between them like this:
Vue.component('myComponent', {
template: "<button @click=\"$parent.currentComponent = 'myComponent1'\"></button>"
}
Now, I'd like to pass props to myComponent1
.
How can I pass these props when I change the component type to myComponent1
?
propName="propValue"
. Is that your question? – thanksd<myComponent1 propName="propValue">
I change the component programmatically with$parent.currentComponent = componentName
– Epitouille<div :is="currentComponent"></div>
. That's where you'd add the attribute. – thanksdmyComponent1
take props andmyComponent2
doesn't take props – Epitouille