当前位置:   article > 正文

Ant Design Vue 框架的a-table自定义表头样式和内容_antd table 自定义表头

antd table 自定义表头

注:开发环境vue2,ant版本1.7.8

ant版本不同api有所不同

 需求:表头要显示红色星星,操作栏展示删除按钮

 

 1、script中创建表头

  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. columns: [
  6. {
  7. dataIndex: 'value',
  8. slots: { title: 'titleValue' },//表头插槽
  9. scopedSlots: { customRender: 'value' },//表格内容插槽
  10. align: 'center',
  11. width: 240,
  12. {
  13. dataIndex: 'level',
  14. scopedSlots: { customRender: 'level' },
  15. slots: { title: 'titleLevel' },
  16. align: 'center'
  17. },
  18. {
  19. dataIndex: 'note',
  20. scopedSlots: { customRender: 'note' },
  21. slots: { title: 'titleNote' },
  22. align: 'center'
  23. },
  24. {
  25. title: '备注',
  26. dataIndex: 'market',
  27. scopedSlots: { customRender: 'market' },
  28. align: 'center'
  29. },
  30. {
  31. title: '操作',
  32. dataIndex: 'operation',
  33. scopedSlots: { customRender: 'operation' },
  34. align: 'center',
  35. width: 50
  36. }
  37. ]
  38. }
  39. }
  40. }
  41. </script>

2、在template中引用

  1. <template>
  2. <div>
  3. <a-table
  4. :rowKey="
  5. (record, index) => {
  6. return index
  7. }"
  8. :columns="columns"
  9. :data-source="form.editList"
  10. :pagination="false">
  11. <!-- 自定义表头-->
  12. <span slot="titleValue" class="form-table-heard">
  13. 分值区间
  14. </span>
  15. <span slot="titleLevel" class="form-table-heard">
  16. 评价等级
  17. </span>
  18. <span slot="titleNote" class="form-table-heard">
  19. 评价说明
  20. </span>
  21. <!--自定义内容-->
  22. <span slot="operation" slot-scope="text, record,index">
  23. <a-button name="删除" btnType="primary" :isDanger="true"
  24. @click="handleDelete(index)"/>
  25. </span>
  26. </a-table>
  27. </div>
  28. </template>
  29. <style lang="less" scoped>
  30. .form-table-heard:before {
  31. content: '*';
  32. color: red;
  33. }
  34. </style>

3、Ant官网地址

ant的table官网地址icon-default.png?t=M666https://1x.antdv.com/components/table-cn/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/897051
推荐阅读
相关标签
  

闽ICP备14008679号