naive-ui-admin BasicTable 列表操作栏显示图标icon

本文介绍了如何在Vue项目中使用BasicTable组件时,自定义列并添加图标操作,包括引入ionicons5中的图标、设置空label、使用n-button和n-icon组件以及添加自定义工具提示属性。
摘要由CSDN通过智能技术生成

效果图

在使用BasicTable的页面添加引用,这里随便弄了个icon

import { GameController } from "@vicons/ionicons5"

 自定义列

const actionColumn = reactive({
  width: 180,
  title: "操作",
  key: "action",
  fixed: "right",
  render(record: any) {
    return h(TableAction, {
      style: "text",
      actions: [
        {
          label: "",
          icon: GameController,
          toolTip: "查看",
          onClick: view.bind(null, record)
        }
      ]
    });
  }
});

 这里label设置为空,icon就是刚刚导入的图标,toolTip是自定义属性,在原来封装好的组件里添加的,不然只有一个图标可能不是很明确。

自定义的如下:

打开components/Table/src/components/TableAction.vue ,修改n-button 里的内容。

<n-button v-bind="action" class="mx-1">
          {{ action.label }}
          <template #icon v-if="action.hasOwnProperty('icon')">
            <n-tooltip trigger="hover">
              <template #trigger>
                <n-icon :component="action.icon" />
            </template>
        {{ action.toolTip }}
        </n-tooltip>
    </template>
</n-button>

然后组件的props添加toolTip字段

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值