vue3 api不支持nextTick, 而nextTick是很常用的方法,我该怎么开发或用什么方法代替
![ICanHelp](https://img-cdn-tc.dcloud.net.cn/account/identicon/1ae46d58f2dd546cbd9d9d8b628cd8ca.png)
ICanHelp
- 发布:2022-08-24 11:39
- 更新:2023-06-21 14:49
- 阅读:891
vue3 api不支持nextTick
分类:uni-app
![y***@qq.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/322e4eb17eba20e2d981eb84421b0520.png)
可以使用 getCurrentInstance 调用 $nextTick 方法
import { getCurrentInstance } from 'vue';
export function useNextTick() {
const currentInstance = getCurrentInstance();
// vue3 api nextTick 小程序不支持
return async function nextTick(fn?: any) {
return currentInstance?.proxy?.$nextTick.call(currentInstance?.proxy, fn);
}
}
ICanHelp (作者)
我在setup怎么调用$nextTick呢?
2022-09-09 09:43
CODE_XU
回复 ICanHelp: import { nextTick } from 'vue'
2022-09-09 10:20
ICanHelp (作者)
回复 CODE_XU: 但是微信小程序不支持
2022-09-10 15:27
cookUni
实测hbx3.8.6下app-nvue组件内使用无效
2023-07-06 12:02