css - create table using weex
问题描述
I need to build an app that has a table. I tried using html <table>
tags to build a table. Even though it shows the table as i require when i run using npm run serve
when i build an apk and run it on my android device the output is messed up.
Does anyone know how to build a table in weex.
And does anyone have any good documentations or tutorials regarding weex.
thanks
解决方案
正如其他人所评论的那样,Weex 不使用 HTML,而是使用看起来相似的 XML 语法。所以你需要实现类似于 using only <div>
s 的东西。我必须这样做,所以我不妨把它贴在这里。
<template>
<div class="table">
<div class="row heading">
<div class="cell headingColumn">Table</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
<div class="row">
<div class="cell headingColumn">Row 1</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
<div class="row">
<div class="cell headingColumn">Row 2</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
</div>
</template>
<style scoped>
.table {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
height: 60px;
}
.cell {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
/*width: 100px;*/
padding: 20px;
}
.heading {
background-color: grey;
font-weight: bold;
}
.headingColumn {
width: 120px;
}
</style>
将其复制并粘贴到 dotwe.org 中,它将在 Android 和 Web 中按预期工作和呈现。
作为旁注,如果您min-width
为列指定固定宽度(或 s),则样式会容易得多。这就是为什么我指定了一个.headingColumn
类并且里面有一个注释width:100px
值.cell
。
顺便说一句,您可能需要编辑并在其中添加一个标签,其中包含您想要的文本内容。
推荐阅读
- mockito - Mockito(如何正确模拟嵌套对象)
- flutter - 如何使用 SizeChangedLayoutNotifier?
- go - 避免Golang界面中的getter的解决方案
- php - 从 mysql 5.7.28 中检索阿拉伯语脚本
- python - 获取元组列表中的特定元素
- c++ - 如何在 Visual Studio Code 的 CMake/Build 输出控制台中解决奇怪的字符
- c# - Razor,.Net 核心:可选字段被创建为具有空值的对象
- docker - 章鱼工作环境中无法识别术语 docker
- python - setuptools 包或 setup.py 是否用于安装以外的任何其他用途?喜欢在包中查找要导入的模块?
- python - 在 Pandas 的帮助下,使用 seaborn 或 python 中的 plotly 对两个折线图进行分组