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>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.

具体可以参考下: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>标签
875浏览 • 1回复 待解决
HarmonyOS TextInput是否支持文本
946浏览 • 1回复 待解决
HarmonyOS 如何支持表情和文本
1843浏览 • 2回复 待解决
HarmonyOS 推送设备不支持
861浏览 • 1回复 待解决
HarmonyOS 编码集不支持
782浏览 • 1回复 待解决
Toggle isOn不支持$$?
837浏览 • 1回复 待解决
web组件不支持localstorage
1514浏览 • 1回复 待解决
HarmonyOS image不支持mask吗
854浏览 • 1回复 待解决
HarmonyOS @State不支持HashMap吗
763浏览 • 1回复 待解决
HarmonyOS Span不支持n换行
783浏览 • 1回复 待解决
HarmonyOS color文件不支持rgba吗
826浏览 • 1回复 待解决
HarmonyOS RN使用datetimePicker显示不支持
795浏览 • 1回复 待解决
HarmonyOS ArkTD不支持any,如何替换
783浏览 • 1回复 待解决
http类不支持cancel方法
913浏览 • 1回复 待解决
HarmonyOS 文本超出容器
1260浏览 • 1回复 待解决
HarmonyOS 文本点击事件
1550浏览 • 1回复 待解决