子组件 Prop 一个参数:
height: {
type: Number,
default: 800,
}
在父组件中引用子组件
<child :height=height />
<child />
在子组件的 created 方法中有没有办法知道父组件到底有没有传值过来?就是有没有在父组件中有没有写上:height=height ?
还有一个问题:
<child :height=height @test="test" />
在这种情况下,有没有什么好的方法保证 height 和 @click 同时设置或者同时不设置?因为我这个 test 是为了修改 height 的值去更新子组件,要是没有设置 height,那这个 test 就没有意义了。