国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Iview Table組件中各種組件擴展的使用

2024-05-06 15:28:34
字體:
來源:轉載
供稿:網友

一、Iview Table 組件 多選框選中和禁選設置

Table添加多選框

通過給 columns 數據設置一項,指定  type: 'selection' ,即可自動開啟多選功能。

正確使用好以下事件,可以達到需要的效果:

@on-select ,選中某一項觸發,返回值為  selection  和  row ,分別為已選項和剛選擇的項。 @on-select-all ,點擊全選時觸發,返回值為  selection ,已選項。 @on-selection-change ,只要選中項發生變化時就會觸發,返回值為  selection ,已選項。
<template> <div>  <Table ref="selection" :columns="columns" :data="data" @on-selection-change="selectChange"></Table> </div></template><script>  export default {      data () {        return {          columns: [ { type: 'selection', width: 60, align: 'center' }, { title: 'Name', key: 'name' }]        }      },      methods: {        selectChange: function (data) {          console.log(data[i].name)        }      }</script>

給 data 項設置特殊 key _checked: true 可以默認選中當前項。

給 data 項設置特殊 key _disabled: true 可以禁止選擇當前項。

例如:

for (var i = 0; i < res.data.list.length; i++) { if (res.data.list[i].status === '1') {  res.data.list[i]._disabled = true // 設置復選框禁用  res.data.list[i]._checked= true // 設置復選框選中狀態 }}

二、Iview Table 組件中點擊Icon彈出Poptip的寫法

1.圖標禁用方式

{ title: '撤銷', key: 'operate', width: 70, fixed: 'right', render: (h, params) => {  if (params.row.status === '1') { // 選中當前行信息   return h('div', [    h('div', [     h('Poptip', {      props: {       confirm: true,       title: '確定要撤銷嗎!'      },      on: {       'on-ok': () => {        this.cancelFunction(params.index)       }      }     }, [      h('Button', {       props: {        shape: 'circle',        icon: 'md-return-left'       }      })     ])    ])   ])  } else {   return h('div', [    h('Button', {     props: {      shape: 'circle',      icon: 'md-return-left',      disabled: true // 禁用圖標     }    })   ])  } }},

2.圖標禁用方式

{ title: '修改', key: 'operate', fixed: 'right', width: 70, textAlign: 'right', render: (h, params) => {  return h('div', [   h('Button', {    props: {     shape: 'circle',     icon: 'ios-paper-plane',     disabled: params.row.status !== '0'    },    on: {     click: () => {      this.editFunction(params.index)     }    }   })  ]) }},

三、四元運算符 : 多個三元運算符 嵌套

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 瑞安市| 沙洋县| 盘锦市| 宝山区| 青海省| 富宁县| 勃利县| 咸阳市| 辰溪县| 平泉县| 宕昌县| 武隆县| 张家口市| 镇平县| 县级市| 泌阳县| 商南县| 陆良县| 宁强县| 雷山县| 卫辉市| 阿鲁科尔沁旗| 昌宁县| 临颍县| 龙胜| 于都县| 堆龙德庆县| 桑植县| 贵南县| 徐州市| 云浮市| 临夏县| 武川县| 浏阳市| 六盘水市| 沐川县| 邮箱| 峨眉山市| 泸溪县| 江油市| 吉木萨尔县|