HarmonyOS 动态import遇到错误:Failed to resolve the requested entryPoint. baseFileName
我在hap中通过 import { QuoteService } from ‘InterfaceLib’ 来调用的时候是正常的,但尝试上述动态导入时候,遇到了错误:
[ecmascript] Failed to resolve the requested entryPoint. baseFileName : .......
QuoteService.ets:
export class QuoteService implements QuoteInterface{
serviceName: string = "QuoteService"
constructor(serviceName: string) {
this.serviceName = serviceName
}
description(): string {
return this.serviceName + " description"
}
quoteMethod(): void {
console.log('call quoteMethod')
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
InterfaceLib的Index.ets:
export { QuoteService } from './src/main/ets/InterfaceService/QuoteService'
export { QuoteInterface } from './src/main/ets/InterfaceService/QuoteInterface'
- 1.
- 2.
hap:
let inter = 'InterfaceLib'
import(inter).then((ns: ESObject) => {
let quoteInstance: ESObject = new ns.QuoteService();
console.log(quoteInstance.description())
})
- 1.
- 2.
- 3.
- 4.
- 5.
经过调试发现:
let inter = 'interfacelib’改成小写可以成功。
import使用以下两种方式都可以
import { QuoteService } from 'InterfaceLib'
import { QuoteInterface } from 'interfacelib'
- 1.
- 2.
为什么动态import的时候只有小写interfacelib可以?
HarmonyOS
赞
收藏 0
回答 1
相关问题
HarmonyOS 动态import失败
754浏览 • 1回复 待解决
安装HarmonyOS NEXT时遇到“INSTALL_FAILED_APP_SOURCE_NOT_TRUSTED”错误,应如何解决?
1044浏览 • 1回复 待解决
HarmonyOS import动态导入库失败
621浏览 • 1回复 待解决
HarmonyOS 动态import so使用问题
693浏览 • 1回复 待解决
HarmonyOS import动态导入绝对路径
1263浏览 • 1回复 待解决
ArkTS import导入napi模块结果错误
3506浏览 • 0回复 待解决
HarmonyOS源码编译错误 importerror:cannot import name
5591浏览 • 1回复 已解决
动态import 变量表达式
1877浏览 • 1回复 待解决
HarmonyOS 动态import变量表达式做反射
661浏览 • 2回复 待解决
HarmonyOS 关于动态import找不到模块的问题咨询
1511浏览 • 1回复 待解决
HarmonyOS 函数中调用动态import,如何设定返回类型?
674浏览 • 1回复 待解决
HarmonyOS 变量动态import是否能支持har包
734浏览 • 1回复 待解决
HarmonyOS 使用convertXML.convertToJSObject()api遇到解析错误问题
926浏览 • 1回复 待解决
什么导入场景中适合使用动态import?
1087浏览 • 1回复 待解决
有没有和我一样遇到previewer读取loading Failed的?
9642浏览 • 1回复 待解决
动态设置文本导致致命错误
7714浏览 • 1回复 待解决
HarmonyOS HSP模块间能通过动态import依赖解耦吗
741浏览 • 0回复 待解决
HarmonyOS 使用动态import时,项目是否一定要配置runtimeOnly?
738浏览 • 1回复 待解决
HarmonyOS GattClientDevice.connect出现Error: BussinessError 2900099: Operation failed错误
895浏览 • 1回复 待解决
INSTALL_FAILED_SILENT_PERMISSIONS_NOT_GRANTED错误怎么解决啊?
4335浏览 • 1回复 待解决
在调用import network from '@system.network'的时候,遇到了这个报错
2667浏览 • 1回复 待解决
Could not resolve all artifacts for configuration ':classpath'.
7131浏览 • 1回复 待解决
HarmonyOS task.on('failed') 无法拿到具体的错误信息
1003浏览 • 1回复 待解决
请检查oh-package.json5的dependencies里InterfaceLib的大小写 以及build-profile.json5里buildOption下packages里的InterfaceLib大小写。动态引入包名是需要区分大小写的,而 import { QuoteService } from 'InterfaceLib’的方式不用区分。