uViewUI
uViewUI
  • 发布:2024-04-09 16:44
  • 更新:2024-04-10 09:11
  • 阅读:84

【已解决】getCurrentInstance在vue3的小程序环境无效

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: M2 Max

HBuilderX类型: 正式

HBuilderX版本号: 4.08

第三方开发者工具版本号: 1.06.2402040 darwin-arm64

基础库版本号: 3.3.5

项目创建方式: HBuilderX

示例代码:

<template>
<view class="">
222
</view>
</template>

<script setup>
console.log(getCurrentInstance())
</script>

操作步骤:

在hx中运行到微信小程序开发工具

预期结果:

getCurrentInstance可在小程序生效

实际结果:

报方法不存在

bug描述:

getCurrentInstance在微信小程序中无效,报方法不存在,在文档中有说明getCurrentInstance在小程序是可用的。

2024-04-09 16:44 负责人:无 分享
已邀请:
哈哈柚

哈哈柚

需要引入,不建议使用

import { getCurrentInstance } from "vue";
  • uViewUI (作者)

    确实如此,失误了。

    以前在vue2,包括现在的vue3 app,uni-app x app中,又是不需要import就能用的。

    2024-04-10 10:20

要回复问题请先登录注册