目前没有表格组件,暂时只能使用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) } } }
目前没有表格组件,暂时只能使用web组件引入一个本地的html,在html中绘制一个表格。demo如下: