查看: 39|回复: 0

vxe-table 如何在单元格内容渲染成可点击复制的文本

[复制链接]

1

主题

0

回帖

0

积分

积极分子

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2008-4-19
发表于 2025-9-18 09:07:00 | 显示全部楼层 |阅读模式

vxe-table 如何在单元格内容渲染成可点击复制的文本

查看官网:https://vxetable.cn
gitbub:https://github.com/x-extends/vxe-table
gitee:https://gitee.com/x-extends/vxe-table

通过 cellRender.name='VxeText',设置参数 clickToCopy=true 就可以开启文本复制功能,点击复制回会自动将文本复制到剪贴板


<template>
  <div>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script setup>
import { reactive } from 'vue'

const roleCellRender = reactive({
  name: 'VxeText',
  props: {
    clickToCopy: true
  }
})

const addressCellRender = reactive({
  name: 'VxeText',
  props: {
    clickToCopy: true,
    status: 'error'
  }
})

const gridOptions = reactive({
  border: true,
  showOverflow: true,
  columns: [
    { type: 'seq', width: 70 },
    { field: 'name', title: 'Name', minWidth: 200 },
    { field: 'role', title: 'Role', width: 120, cellRender: roleCellRender },
    { field: 'address', title: 'Address', width: 300, cellRender: addressCellRender }
  ],
  data: [
    { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
    { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
    { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
    { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
  ]
})
</script>

https://gitee.com/x-extends/vxe-table



来源:https://www.cnblogs.com/qaz666/p/19098045
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部