HarmonyOS 有table表格控件吗?

如题:HarmonyOS 有table表格控件吗?

阅读 546
1 个回答

目前没有表格组件,暂时只能使用web组件引入一个本地的html,在html中绘制一个表格。demo如下:

import web_webview from '@ohos.web.webview'

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

  build() {
    Column() {
      Button("点击此处,加载HTML富文本").onClick(() => {
        this.controller.loadData(`<html> <head> <style> .table-font-size{ font-size:20px; } </style> </head> <body bgcolor=\"white\"> <table width="1000" border="5" height="1000"> <tr class="table-font-size"> <th>Month</th> <th>Month</th> </tr> <tr class="table-font-size"> <th>Month</th> <th>Month</th> </tr> <tr class="table-font-size"> <th>Month</th> <th>Month</th> </tr> <tr class="table-font-size"> <th>Month</th> <th>Month</th> </tr> </table> </body></html>`, "text/html", "UTF-8");
      }) // 通过$rawfile加载本地资源文件。
      Web({ src: 'www', controller: this.controller }).javaScriptAccess(true).domStorageAccess(true).fileAccess(true)
      // .defaultFontSize(this.fontSize)
    }
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进