HarmonyOS 鸿蒙Next 使用ArkTS web组件,如何将本地的.js文件注入到web界面中
HarmonyOS 鸿蒙Next 使用ArkTS web组件,如何将本地的.js文件注入到web界面中
使用ArkTS web组件,如何将本地的.js文件注入到web界面中
        
          2 回复
        
      
      
        Web({ src: $rawfile('index.html'), controller: this.controller })
  .onControllerAttached(() => {
    let context = getContext(this) as common.UIAbilityContext;
    // entry : hap包名,script.js:读取的文件名
    context.createModuleContext('entry').resourceManager.getRawFileContent('script.js')
      .then(value => {
        let rawfile = value.buffer;
        this.controller.runJavaScriptExt(rawfile).then((e: ESObject) => {
          console.log(e)
        }).catch((err: ESObject) => {
          console.log(err)
        })
      })
  }) 更多关于HarmonyOS 鸿蒙Next 使用ArkTS web组件,如何将本地的.js文件注入到web界面中的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
        
      
                  
                  
                  

