HarmonyOS 富文本不支持trthtd标签

在开发过程中,发现官方库和三方库没有支持tr\th\td标签(表格)的组件,有解决办法吗?

HarmonyOS
2024-12-25 15:27:32
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa

可以使用web导入html来实现表格组件的搭建,将html文件放入rawfile,前端通过web进行引入:

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

@Entry
@Component
struct WebComponent {
  controller: web_webview.WebviewController = new web_webview.WebviewController()
  build() {
    Column() {
      Web({ src: $rawfile('index.html'), controller: this.controller })
    }
  }
}

//html:
<!DOCTYPE html>
  <html lang="zh-CN">
  <head>
  <meta charset="UTF-8">
  <title>示例表格</title>
  <style>
  table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  border: 1px solid black;
  padding: 8px;
  text-align: left;
}
th {
  background-color: #f2f2f2;
}
</style>
  </head>
  <body>

  <h2>示例表格</h2>

  <table>
  <caption>这是一个示例表格</caption>
  <thead>
  <tr>
  <th>姓名</th>
  <th>年龄</th>
  <th>性别</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>张三</td>
  <td>30</td>
  <td>男</td>
  </tr>
  <tr>
  <td>李四</td>
  <td>28</td>
  <td>女</td>
  </tr>
  <tr>
  <td>王五</td>
  <td>25</td>
  <td>男</td>
  </tr>
  </tbody>
  <tfoot>
  <tr>
  <td colSpan="3">总计</td>
  </tr>
  </tfoot>
  </table>

  </body>
  </html>

具体可以参考下:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5

分享
微博
QQ
微信
回复
2024-12-25 16:46:26
相关问题
HarmonyOS SVG文件不支持<text>标签
164浏览 • 1回复 待解决
HarmonyOS TextInput是否支持文本
280浏览 • 1回复 待解决
HarmonyOS 推送设备不支持
45浏览 • 1回复 待解决
HarmonyOS 编码集不支持
158浏览 • 1回复 待解决
Toggle isOn不支持$$?
165浏览 • 1回复 待解决
web组件不支持localstorage
909浏览 • 1回复 待解决
HarmonyOS image不支持mask吗
183浏览 • 1回复 待解决
HarmonyOS Span不支持n换行
141浏览 • 1回复 待解决
HarmonyOS @State不支持HashMap吗
64浏览 • 1回复 待解决
HarmonyOS 如何支持表情和文本
888浏览 • 2回复 待解决
HarmonyOS ArkTD不支持any,如何替换
142浏览 • 1回复 待解决
HarmonyOS RN使用datetimePicker显示不支持
212浏览 • 1回复 待解决
HarmonyOS color文件不支持rgba吗
146浏览 • 1回复 待解决
http类不支持cancel方法
309浏览 • 1回复 待解决
HarmonyOS 不支持通过索引访问字段
491浏览 • 1回复 待解决
HarmonyOS Object不支持 ... 展开符吗?
401浏览 • 1回复 待解决