Vue Component simter-vue-thead
Define table's thead tag by structured data. Such as columns = ["X1", "X2"]
or
columns = ["X1", {label: "X2", children: ["X21", "X22"]}]
.
Demo or document is here.
Core properties:
Name_________ | Require | ValueType | Description |
---|---|---|---|
columns | true | [{}] | Define table columns |
├ label | true | String | The column's visible text |
├ width | false | String | The column's width, such as '2em' |
├ children | false | [{}] | The child group columns. id and width will be ignored if define this property |
├ headerClass | false | String | The specific class for this column's header cell th element |
├ headerStyle | false | String | The specific style for this column's header cell th element |
classes | false | {} | Define component class |
├ thead | false | String | thead class, follow Vue Class Bindings |
├ row | false | String | thead/tr class, follow Vue Class Bindings |
├ cell | false | String | thead/tr/th class, follow Vue Class Bindings |
styles | false | {} | Define component style |
├ thead | false | String | thead class, follow Vue Style Bindings |
├ row | false | String | thead/tr class, follow Vue Style Bindings |
├ cell | false | String | thead/tr/th class, follow Vue Style Bindings |
Develop
yarn install // or npm install
npm run dev
Use parcel to run the development debug.
Build
npm run build
Use rollup package the component to dist
directory.
Usage
Example 1 : Simple Columns
Js:
el: "#sample" data: columns: "X1" "X2" "X3" components: "st-thead": thead
Html template:
...
Generated html:
| X1 | X2 | X3 | X1 X2 X3 ...
Example 2 : Group Columns
Use children
key to define the group.
Js:
el: "#sample" data: columns: "X1" label: "X2" children: "X21" "X22" label: "X3" children: "X31" "X32" components: "st-thead": thead
Html template:
...
Generated html:
| X1 | X2 | X3 || | X21 | X22 | X31 | X32 | X1 X2 X3 X21 X22 X31 X32 ...
Example 3 : Complex Group Columns
Use children
key to define any level nested group columns.
Js:
el: "#sample" data: columns: label: "X1" label: "X2" children: label: "X21" label: "X22" label: "X3" label: "X4" children: label: "X41" children: label: "X411" label: "X412" label: "X42" components: "st-thead": thead
Html template:
...
Generated html:
| X1 | X2 | X3 | X4 || | X21 | X22 | | X41 | X42 || | | | | X411 | X412 | | X1 X2 X3 X4 X21 X22 X41 X42 X411 X412 ...