iview中render函數監聽事件


iview的table中添加datepicker
在組件中嵌套組件,如果需要監聽子組件的自定義事件,
應該使用render中的on:{
  'on-change' () => {
    console.log('這里會觸發子組件的事件')
  }
}

代碼片段

{
   title: '發布時間',
   key: 'pubdate',
   sortable: true,
   width: 280,
   render: (h, params) => {
     return h('div', [
        h('DatePicker', {
          props: {
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm',
            placeholder: '選擇日期和時間',
            value: params.row.pubdate
        },
        style: {
          marginRight: '5px'
        },
        on: {
          'on-change': (val) => {
            console.log('發布時間1')
          }
        }
      })
    ])
  }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM