子组件的代码
props: { alarm: { type: Object, default () { return { lon: 0, lat: 0 } } }, }
对 alarm 使用watch H5没有生效。
父组件:添加nextTick解决顺序问题
onLoad(option) {
self_ = this;
if (option.alarm) {
let item = JSON.parse(decodeURIComponent(option.alarm));
if (item) {
this.$nextTick(()=>{ //解决H5渲染慢,子组件watch不到变化的
this.alarmItem = item
})
}
}
},
其他备注
<!--注意事项-->
<!-- 设置flex:1的时候,如果不设置overflow: hidden;会超出 -->
<!-- 当view在父容器是display: flex;时候,宽度不会自动铺满 -->
<!-- 当view在父容器是不是display: flex;时候,子容器margin: 50rpx; width: 100%;会超出屏幕 或者不要设置100%只靠margin铺满-->