我对如何正确地将组件绑定在一起感到很困惑。 我在全球注册了两个组件:
ggplot(transect_weather_summary, aes(x = factor(WindDirCompass),
y = Sum.of.Incidents)) +
geom_bar(stat = "identity", fill = "#990033") +
labs(title = "", x = "Wind direction", y = "Number of incidents")+
scale_x_discrete(drop=FALSE)
在父模板中,我包含了这样的子组件:
Vue.component('product-welcome-component', {
template: '#product-welcome-template',
props: ['showModal'],
onCreate(){
showModal = false;
}
});
Vue.component('product-create-modal-component', {
template: '#create-modal-template'
});
问题是(其中之一)是我的create-modal-component始终显示,无论showModal的值如何,实际上我可以放入v-if =“1 === 2”它仍然会秀。
我确信这不是注册父/子组件的正确方法,但我似乎找不到合适的例子。大多数情况下,我看到父母是app实例,它有一个'child'组件的子项,然后他们可以进行通信。
我有一种感觉,在父模板中包含子组件是不好的做法,因为它使父母强耦合。
任何帮助将不胜感激,谢谢!
答案 0 :(得分:0)
您拥有showModal
作为product-welcome-component
的道具,但您尝试在创建时将其设置为false,但您必须使用this
中的created
来访问{ {1}},如下所示:
showModal
但是你说Vue.component('product-welcome-component', {
template: '#product-welcome-template',
props: ['showModal'],
onCreate(){
this.showModal = false;
}
});
即使你做product-create-modal-component
,也不应该这样。你能不能创造一个案例的小提琴。