这篇文章主要介绍了iview的table组件中使用选择框,日期,可编辑表格,超链接等组件。

1.select选择组件

// tableColumn数组响应对象需要传入一个固定的option数组,如果该数组是异步动态生成的该组件不能正常渲染,因为在获取option数组之前table渲染时option是undefined。
supportSelect(item) {
item.render = (h, params)=>{
return h('Select', {
props: {
value: params.row[params.column.key],
size: 'small',
transfer: true
},
on: {
'on-change': (val)=>{
this.insideTableData[params.index][params.column.key] = val
}
},
},item.option.map(item=>{
return h('Option', {
props: {
value: item.value || item,
label: item.label || item
}
}, item.label || item)
}))
}
return item
}

2.可编辑表格

// 可编辑表格使用了contenteditable属性,使得表格编辑更加简单干净
supportEdit(item, index){
item.render = (h, params)=>{
return h('div', {
style: {
padding: '4px 0',
width: '100%'
},
props: {
value: this.insideTableData[params.index][params.column.key]
},
attrs: {
contenteditable: this.editable,
title: '点击可编辑'
},
on: {
'blur': evt=>{
evt.target.value = evt.target.innerText || params.row[params.column.key]
params.row[params.column.key] = evt.target.innerText
this.insideTableData[params.index][params.column.key] = evt.target.innerText
}
}
}, params.row[params.column.key])
}
return item
}

3.日期组件

// 使用iview的DatePicker组件渲染就行
supportDate(item){
item.render = (h, params)=>{
return h('DatePicker', {
props: {
clearable: false,
placeholder: '请选择日期',
value: params.row[params.column.key],
type: 'date',
format: 'yyyy-MM-dd',
size: 'small'
},
on: {
'on-change': (val)=>{
this.insideTableData[params.index][params.column.key] = val
}
}
})
}
return item
}

4.表格中添加超链接

// 这里的handleLink方法是在table组件中定义好的使用$emit让父组件调用
supportLink(item){
item.render = (h, params)=>{
return h('a', {
style: {
textDecoration: 'underline'
},
on: {
'click': ()=>{
this.handleLink(params.row)
}
}
}, params.row[params.column.key])
}
return item
}

iview的table组件中加入超链接组件,可编辑组件,选择组件,日期组件的更多相关文章

  1. vue组件中的样式属性:scoped,解决在父组件中无法修改子组件样式问题

    Scoped CSS规范是Web组件产生不污染其他组件,也不被其他组件污染的CSS规范. vue组件中的style标签标有scoped属性时表明style里的css样式只适用于当前组件元素,它是通过使 ...

  2. vue组件中使用iframe元素

    需要在本页面中展示vue组件中的超链接,地址栏不改变的方法: <template> <div class="accept-container"> <d ...

  3. Source Qualifter组件中sqlquery过长导致截取

    问题:Source Qualifter组件中sqlquery过长导致截取原因:Source Qualifter组件中sqlquery可以接受的最长字符数是32767个字符,超过这个数字会导致截取解决方 ...

  4. Vue系列之 => 组件中的data和methods

    使用data <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  5. Vue组件中引入jQuery

    一.安装jQuery依赖 在使用jQuery之前,我们首先要通过以下命令来安装jQuery依赖: npm install jquery --save # 如果你更换了淘宝镜像,可以使用cnpm来安装, ...

  6. vue框架之自定义组件中使用v-model

    通常 vue在html常见表单空间支持v-model双向绑定例如 <input v-model="message" placeholder="edit me&quo ...

  7. 微信小程序在组件中获取界面上的节点信息wx.createSelectorQuery

    节点信息查询 API 可以用于获取节点属性.样式.在界面上的位置等信息. 最常见的用法是使用这个接口来查询某个节点的当前位置,以及界面的滚动位置. 示例代码: const query = wx.cre ...

  8. VUe.js 父组件向子组件中传值及方法

    父组件向子组件中传值 1.  Vue实例可以看做是大的组件,那么在其内部定义的私有组件与这个实例之间就出现了父子组件的对应关系. 2. 父子组件在默认的情况下,子组件是无妨访问到父组件中的数据的,所以 ...

  9. vue组件中的data为什么是函数?

    一.vue组件中的data为什么是函数 为了保证组件的独立性 和 可 复用性,data 是一个函数,组件实例化的时候这个函数将会被调用,返回一个对象,计算机会给这个对象分配一个内存地址,你实例化几次, ...

随机推荐

  1. pip install失败报错解决方案

    cmd pip install 某些包时报错 pip install Consider using the `--user` option or check the permissions. 只需要p ...

  2. SpringMVC:HandlerInterceptor log 日志

    springMVC:HandlerInterceptor拦截器添加系统日志(权限校验)代码收藏 - LinkcOne - CSDN博客https://blog.csdn.net/qq_22815337 ...

  3. PHP如何防止注入及开发安全

    1.PHP注入的基本原理 程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对 用户输入数据的合法性进行判断,使应用程序存在安全隐患.用户可以提交一段数据 库查询代码,根据程序返回 ...

  4. osg创建灯光

    添加光照 osg::ref_ptr<osg::Node> MyOSGLoadEarth::CreateNode() { osg::ref_ptr<osg::Group> _ro ...

  5. python 调用java脚本的加密(没试过,先记录在此)

    http://lemfix.com/topics/344 前言 自动化测试应用越来越多了,尤其是接口自动化测试. 在接口测试数据传递方面,很多公司都会选择对请求数据进行加密处理. 而目前为主,大部分公 ...

  6. LeetCode_389. Find the Difference

    389. Find the Difference Easy Given two strings s and t which consist of only lowercase letters. Str ...

  7. attribute__关键字举例之visibility

    /** @file visibilityT.c * @note * @brief * @author * @date 2019-6-20 * @note v1.0.0 Created * @histo ...

  8. sentinel搭建redis集群的注意事项

    一.protected-mode 默认情况下,redis node和sentinel的protected-mode都是yes,在搭建集群时,若想从远程连接redis集群,需要将redis node和s ...

  9. web端自动化——Selenium Server环境配置

    Selenium Server环境配置 下面下载.配置并运行Selenium Server. ①    下载 Selenium Server. 下载地址为:https://pypi.python.or ...

  10. 最新 中细软java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.中细软等10家互联网公司的校招Offer,因为某些自身原因最终选择了 中细软.6.7月主要是做系统复习.项目复盘.LeetC ...