VUE对ElTableColumn进行扩展

这次给大家带来VUE对ElTableColumn进行扩展,VUE对ElTableColumn进行扩展的注意事项有哪些,下面就是实战案例,一起来看一下。

ElTableColumn本来是这个样子的:

VUE对ElTableColumn进行扩展

要做成的是这个样子:

VUE对ElTableColumn进行扩展

我直接就放代码了,挨着挨着说明太多了。

代码的结构:

VUE对ElTableColumn进行扩展

组件

                     {{fomatMethod(scope.row[prop])}}              import moment from "moment";export default { name: "el-table-column-pro", props: {  prop: {   type: String  },  label: {   type: String  },  width: {   type: Number  },  renderType: {   type: String,   validator: value => ["date", "input", "select"].includes(value)  },  placeholder: {   type: String  },  rederWidth: {   type: String,   default: "230px"  },  param: {   type: String,   default: ""  },  startDate: {   type: String  },  endDate: {   type: String  },  selectList: {   type: Array  },  isClear: {   type: Boolean,   default:true  },  visible: {   type: Boolean,   default: true  },  filterIcon: {   type: String,   default: "el-icon-search"  },  callback: {   type: Function  },  formatter: {   type: Function,   default:(row, column, cellValue)=>cellValue  },  align:{   type:String   },  headerAlign:{   type:String  } }, data() {  return {   formatD:this.filterIcon  }; },  methods: {  fomatMethod(value){   return this.formatter('','',value)  },    renderHeader(createElement, { column, $index }) {   switch (this.renderType) {    case "date":     return this.renderDate(createElement, { column, $index });    case "input":     return this.rederInput(createElement, { column, $index });         case "select":     return this.rederSelect(createElement, { column, $index });        default:     return column.label;   }  },  rederInput(createElement, { column, $index }) {   return createElement(    "p",    {     class: "filters",     style: {      color: column.color     }    },    [     createElement(      "el-popover",      {       props: {        placement: "bottom",        width: "200",        trigger: "click"       }      },      [       createElement("el-input", {        props: {         placeholder: this.placeholder,         value: this.param        },        nativeOn: {         keyup: event => {          if (event.keyCode === 13) {           this.$emit("update:param", event.target.value);           this.callback && this.callback();          }         }        },        on: {         blur: event => {          this.$emit("update:param", event.target.value);          this.callback && this.callback();         }        }       }),       createElement(        "span",        {         slot: "reference"        },        [         column.label,         createElement("i", {          class: this.filterIcon,          style: {           marginLeft: "4px"          }         })        ]       )      ]     )    ]   );  },  rederSelect(createElement, { column, $index }) {   return createElement(    "p",    {     class: "filters",     style: {      color: column.color     }    },    [     createElement(      "el-popover",      {       props: {        placement: "bottom",        width: "200",        trigger: "click"       }      },      [       createElement(        "el-select",        {         props: {          placeholder: this.placeholder,          value: this.param,          clearable: this.isClear         },         on: {          input: value => {           this.$emit("update:param", value);           this.callback && this.callback();          }         }        },        [         this.selectList.map(item => {          return createElement("el-option", {           props: {            value: item.value,            label: item.label           }          });         })        ]       ),       createElement(        "span",        {         slot: "reference"        },        [         column.label,         createElement("i", {          class: this.filterIcon,          style: {           marginLeft: "4px"          }         })        ]       )      ]     )    ]   );  },  renderDate(createElement, { column, $index }) {   return createElement(    "p",    {     class: "filters"    },    [     createElement(      "el-popover",      {       props: {        placement: "bottom",        width: this.rederWidth,        trigger: "click"       }      },      [       createElement("el-date-picker", {        props: {         placeholder: this.placeholder,         value: this.value,         type: "daterange",         rangeSeparator:"至",         startPlaceholder:"开始日期",         endPlaceholder:"结束日期",        },        style: {         width: this.rederWidth        },        on: {         input: value => {          if (value) {           const startDate = moment(value[0]).format("YYYY-MM-DD");           const endDate = moment(value[1]).format("YYYY-MM-DD");           this.$emit("update:startDate", startDate);           this.$emit("update:endDate", endDate);           this.callback && this.callback();          }         }        }       }),       createElement(        "span",        {         slot: "reference"        },        [         column.label,         createElement("i", {          class: this.filterIcon,          style: {           marginLeft: "4px"          }         })        ]       )      ]     )    ]   );  } }};import ElTableColumnPro from './ElTableColumnPro'ElTableColumnPro.install = function(Vue) { Vue.component(ElTableColumnPro.name, ElTableColumnPro);};export default ElTableColumnPro;

登录后复制

安装

import ElTableColumnPro from 'components/ElTableColumnPro/index' .........Vue.use(ElTableColumnPro)

登录后复制

使用

                     

登录后复制

                                  
{{scope.row.content}}

登录后复制                     

相信看了本文案例你已经掌握了方法,更多精彩请关注【创想鸟】其它相关文章!

推荐阅读:

JS里如何验证E-mail正确地址

Vue.js实现自定义登录表单

以上就是VUE对ElTableColumn进行扩展的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2766639.html

(0)
上一篇 2025年3月8日 11:23:48
下一篇 2025年3月1日 22:18:00

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • ElTableColumn添加搜索归纳功能

    这次给大家带来ElTableColumn添加搜索归纳功能,ElTableColumn添加搜索归纳功能的注意事项有哪些,下面就是实战案例,一起来看一下。 公司有一个新的需求,点击ElTableColumn的头部可以进行搜索,这个功能同事已经做…

    2025年3月8日
    200
  • Angular CLI进行单元测试和E2E测试步骤详解

    这次给大家带来Angular CLI进行单元测试和E2E测试步骤详解,Angular CLI进行单元测试和E2E测试步骤的注意事项有哪些,下面就是实战案例,一起来看一下。 第一篇文章是: “使用angular cli生成angu…

    2025年3月8日 编程技术
    200
  • ElTableColumn扩展方法详解

    这次给大家带来ElTableColumn扩展方法详解,ElTableColumn扩展的注意事项有哪些,下面就是实战案例,一起来看一下。 公司有一个新的需求,点击ElTableColumn的头部可以进行搜索,这个功能同事已经做出来了,但是使用…

    2025年3月8日
    200
  • js对数值数组进行去重与优化

    这次给大家带来js对数值数组进行去重与优化,js对数值数组进行去重与优化的注意事项有哪些,下面就是实战案例,一起来看一下。 前言 本文主要介绍了关于js构建二叉树进行数值数组的去重与优化的相关内容,分享出来供大家参考学习,下面话不多说了,来…

    编程技术 2025年3月8日
    200
  • 使用JS进行文件拖拽

    这次给大家带来使用JS进行文件拖拽,使用JS进行文件拖拽的注意事项有哪些,下面就是实战案例,一起来看一下。 1.效果图: 2.源码 #p1 { width: 350px; height: 70px; padding: 10px; borde…

    2025年3月8日
    200
  • table表格内对某列内容进行搜索筛选步骤详解

    这次给大家带来table表格内对某列内容进行搜索筛选步骤详解,table表格内对某列内容进行搜索筛选的注意事项有哪些,下面就是实战案例,一起来看一下。 往往有些时候,我们把数据从数据库读取出来,显示到table里面,而此时来了个新需求,要在…

    2025年3月8日
    200
  • Angular4.x通过路由守卫进行路由重定向步骤详解

    这次给大家带来Angular4.x通过路由守卫进行路由重定向步骤详解,Angular4.x通过路由守卫进行路由重定向的注意事项有哪些,下面就是实战案例,一起来看一下。 需求: 最近在做一个网上商城的项目,技术用的是Angular4.x。有一…

    编程技术 2025年3月8日
    200
  • 如何对微信小程序进行开发

    这次给大家带来如何对微信小程序进行开发,对微信小程序进行开发的注意事项有哪些,下面就是实战案例,一起来看一下。 no.1 背景图不显示 微信小程序里面是允许用户自定义背景图的,但是限定了背景图的路径及地址,之前一直用相对路径来写,微信开发者…

    编程技术 2025年3月8日
    200
  • 怎样使用Angular对服务端进行渲染

    这次给大家带来怎样使用Angular对服务端进行渲染,使用Angular对服务端进行渲染的注意事项有哪些,下面就是实战案例,一起来看一下。 Angular Universal Angular在服务端渲染方面提供一套前后端同构解决方案,它就是…

    2025年3月8日 编程技术
    200
  • 如何使用vue axios进行请求拦截

    这次给大家带来如何使用vue axios进行请求拦截,使用vue axios进行请求拦截的注意事项有哪些,下面就是实战案例,一起来看一下。 axios 简介 axios 是一个基于Promise 用于浏览器和 nodejs 的 HTTP 客…

    编程技术 2025年3月8日
    200

发表回复

登录后才能评论