Replies: 3 comments 5 replies
-
你是想要实现全部加粗吗?是的话,可以把 |
Beta Was this translation helpful? Give feedback.
-
对于一个内部声明了 拿下面的代码例子来说,被插入 <x-table columns="{{columns}}" datasource="{{list}}">'
<fragment s-for="col, index in columns">
<b slot="col-{{col.name}}" key="index">{{row.name}}</b>
</fragment>
<u slot="col-xxx">{{row.name}}</u>
</x-table> 这是符合标准对 slot 行为定义的 |
Beta Was this translation helpful? Give feedback.
-
至于这个需求,其实并不难实现:
所以, var Table = san.defineComponent({
template: `
<table>
<thead><tr><th s-for="col in columns">{{col.label}}</th></tr></thead>
<tbody>
<tr s-for="row in datasource">
<td s-for="col in columns">
<slot var-row="row" var-col="col">{{row[col.name]}}</slot>
</td>
</tr>
</tbody>
</table>
`
}); 在使用的时候,通过 s-is 来动态选择组件。 https://baidu.github.io/san/tutorial/component/#动态子组件 <x-table columns="{{columns}}" datasource="{{list}}">'
<s-cmpt s-is="col.type" col-data="{{col}}" row-data="{{row}}" />
</x-table> |
Beta Was this translation helpful? Give feedback.
-
san 文档中slot 动态命名示例
替换MyComponent template内代码
为
最终dom节点无法渲染出b标签、求解答。
完整代码如下:
Beta Was this translation helpful? Give feedback.
All reactions