如何在 Vue.js created/mounted 钩子中操作并加载异步数据?-灵析社区

一个响亮的昵称

这是方法体 ![https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1725017648845_wZfW.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1725017648845_wZfW.png) 这是在created调用这个方法 ![https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1725017658373_hi6Z.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/community/1725017658373_hi6Z.png) 问题: 通过这个方法获取的数据,我在这个方法的.then后面进行console对res.rows进行输出时,数据是存在的。 将这个Patientdata变量加载进页面时 数据也是存在的。 但是我现在想在created或者是mounted对Patientdata数据进行操作后再加载进页面内,在写操作数据的方法时,发现怎么都获取不到Patientdata的值,都是为空 这是为什么?

阅读量:251

点赞量:0

问AI
怎么说呢就这样吧
方法体: patientListData() { return new Promise((resolve, reject) => { //处理逻辑 resolve() }).catch(...) } // created方法 async created() { ... await patientListData() }