uni.navigateTo({
url:'/pages/new....'
success : () => {
uni.$emit("news",element);
}
})
第二个页面
export default {
name: "news_details",
data() {
return {
title: '',
newData:null,
}
},
onLoad(option) {
let $this = this;
uni.$once("news", (res) => {
console.log("res----",res);
$this.newData = res;
console.log("res----",$this.newData);
})
},
methods: {
}
}
2条答案
按热度按时间bf1o4zei1#
Yes, I also encountered this situation. Under once, $this The newdata value exists, but not in the scope of the outlet, nor in the delay, nor in the mounted
new9mtju2#
不保证onLoad先于navigateTo的success执行
即:你的代码正常的前提是,调用navigateTo时,目标页面先触发onLoad,然后再触发success,