vue render 嵌套 iview Poptip 及on-ok事件

columns4: [
  {
    title: '操作',
    key: 'action',
    width: 150,
    align: 'center',
    render: (h, params) => {
      return h('div', [
        h('Button', {
          props: {
            type: 'primary',
            size: 'small'
          },
        style: {
          marginRight: '5px'
        },
        on: {
          click: () => {
            this.modalShow(params.index)
          }
        }
        }, '編輯'),
        h('Poptip', {
          style:{
            textAlign: 'left'
          },
          props: {
            placement:'left-start',
            confirm: true,
            title: '確定刪除嗎?',
          },
          on: {
            // 必須是箭頭函數寫法
            'on-ok': ()=> {
              //調用刪除方法
              this.remove(params.index)
                console.log('刪除')
            },
            'on-cancel': ()=> {
                console.log('取消')
            }
          }
        },[
          h('Button', {
            props: {
              type: 'error',
              size: 'small'
            },
            on: {
              click: () => {
                //this.remove(params.index)
              }
            }
          }, '刪除')
        ]),
      ]);
    }
  }
],
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章