ICanHelp
ICanHelp
  • 发布:2022-08-24 11:39
  • 更新:2023-06-21 14:49
  • 阅读:891

vue3 api不支持nextTick

分类:uni-app

vue3 api不支持nextTick, 而nextTick是很常用的方法,我该怎么开发或用什么方法代替

2022-08-24 11:39 负责人:无 分享
已邀请:
CODE_XU
  • 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

y***@qq.com

y***@qq.com

可以使用 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);  
  }  
}
1***@qq.com

1***@qq.com

微信小程序不支持怎么搞

1***@qq.com

1***@qq.com

https://uniapp.dcloud.net.cn/tutorial/vue3-api.html#%E5%AE%9E%E4%BE%8B%E6%96%B9%E6%B3%95文档上写的vue3 $nextTick 支持小程序,试过了根本没有用

要回复问题请先登录注册