鸿蒙开发填坑记录 web 组件01

27次阅读
没有评论

共计 491 个字符,预计需要花费 2 分钟才能阅读完成。

// xxx.ets
import web_webview from '@ohos.web.webview'

@Entry
@Component
struct WebComponent {
  controller: web_webview.WebviewController = new web_webview.WebviewController();

  build() {
    Column() {
      // src 不能带协议
      Web({ src: 'www.baidu.com', controller: this.controller })
    }
  }
}

// 需要额外配置当前模块下的 module.json5 文件 requestPermissions 块

{
  "module": {
    "name": "entry",
    "type": "entry",
    "description": "$string:module_desc",
    "mainElement": "EntryAbility",
    "deviceTypes": [
      "default",
      "tablet"
    ],
    "requestPermissions": [
      {
        "name": "ohos.permission.INTERNET"
      }
    ]
  }
}
正文完
 0
Eric chan
版权声明:本站原创文章,由 Eric chan 于2024-03-29发表,共计491字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。