iview中render函數監聽事件

 1 iview的table中添加datepicker
 2 在組件中嵌套組件,若是須要監聽子組件的自定義事件,
 3 應該使用render中的on:{
 4   'on-change' () => {
 5     console.log('這裏會觸發子組件的事件')
 6   }
 7 }
 8 
 9 代碼片斷
10 
11 {
12    title: '發佈時間',
13    key: 'pubdate',
14    sortable: true,
15    width: 280,
16    render: (h, params) => {
17      return h('div', [
18         h('DatePicker', {
19           props: {
20             type: 'datetime',
21             format: 'yyyy-MM-dd HH:mm',
22             placeholder: '選擇日期和時間',
23             value: params.row.pubdate
24         },
25         style: {
26           marginRight: '5px'
27         },
28         on: {
29           'on-change': (val) => {
30             console.log('發佈時間1')
31           }
32         }
33       })
34     ])
35   }
36 }
相關文章
相關標籤/搜索