父组件:
created() {
let res = new Promise((resolve) => {
setTimeout(() => {
resolve('treeDome 运行');
}, 6000);
});
console.log(res)
},
子组件:
created() {
console.log("子组件created执行")
}
发现打印执行顺序,并不对,子组件先打印,父组件后打印
进行改造(进行如下改造,执行顺序也并没有按照期望的那样,先打印父组件再打印子组件):
父组件:
async created() {
let res = await new Promise((resolve) => {
setTimeout(() => {
resolve('treeDome 运行');
}, 6000);
});
console.log(res)
},
子组件:
async created() {
console.log("子组件created执行")
}