1.页面生命周期
image.png_mounted
image.png所以 onshow 去使用 refs 有概率 会拿不到
- 解决方案
包一层 nexttrick
//
onShow() {
console.log('my_page_onShow');
console.log('my_page_onShow_refs:', this.$refs.activityAd);
this.$nextTick(() => {
console.log('my_page_onShow_nextTick');
console.log('my_page_onShow_nextTick_refs:', this.$refs.activityAd);
});
},
onHide() {
console.log('my_page_onHide');
console.log('my_page_onHide_refs:', this.$refs.activityAd);
this.$nextTick(() => {
console.log('my_page_onHide_nextTick');
console.log('my_page_onHide_nextTick_refs:', this.$refs.activityAd);
});
},
created() {
console.log('my_page_created');
console.log('my_page_created_refs:', this.$refs.activityAd);
this.$nextTick(() => {
console.log('my_page_created_nextTick');
console.log('my_page_created_nextTick_refs:', this.$refs.activityAd);
});
},
mounted() {
console.log('my_page_mounted');
console.log('my_page_mounted_refs:', this.$refs.activityAd);
this.$nextTick(() => {
console.log('my_page_mounted_nextTick');
console.log('my_page_mounted_nextTick_refs:', this.$refs.activityAd);
});
},
image.png
网友评论