2***@qq.com
2***@qq.com
  • 发布:2024-11-07 01:07
  • 更新:2024-11-07 13:14
  • 阅读:51

uts在index.uts重新导出export * from “./testexp.uts”,在vue页面调用export * 中的导出会报错

分类:uts

报错为../../../../hello-uts/pages/index/index.vue (2:68): "testexp" is not exported by "../../../../hello-uts/uni_modules/uts-helloworld?uts-proxy", imported by "../../../../hello-uts/pages/index/index.vue".

项目是hello-uts

首先新建uni_modules\uts-helloworld\utssdk\testexp.uts文件,代码如下

export function testexp():void{  
    console.log(123);  
}

其次在uni_modules\uts-helloworld\utssdk\index.uts文件中额外添加一行代码

//原有代码......  
//新增代码  
export * from "./testexp.uts"

最后在pages\index\index.vue文件中导入并调用testexp函数,代码如下

import { callWithJSONParam, callWithStringParam, callWithoutParam, testexp } from "../../uni_modules/uts-helloworld";  
    testexp()

结果报错

2024-11-07 01:07 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

尝试导入hello-uts自带的export * from “...” 也是同样的报错:
../../../../hello-uts/pages/index/index.vue (3:10): "CustomAccessibilityService" is not exported by "../../../../hello-uts/uni_modules/uts-nativepage?uts-proxy", imported by "../../../../hello-uts/pages/index/index.vue".

在pages\index\index.vue文件中额外添加行代码

import { CustomAccessibilityService} from "../../uni_modules/uts-nativepage"  
new CustomAccessibilityService()

要回复问题请先登录注册