当前位置: 首页 > Web前端 > vue.js

如何在vue、jsx中编写自定义指令

时间:2023-03-31 16:04:12 vue.js

使用具有原生vnode数据格式的自定义指令:注意属性名称必须是指令!!!无法更改!//格式constdirectives=[{name:'permission',value:['hangup'],modifiers:{}}]return

//instancerender:(h:any,scope:any)=>{letdirectives,comp=''if(scope.row.payment_status==='付款成功'){if(scope.row.is_hang===1){指令=[{name:'permission',value:['hangup'],modifiers:{}}]comp=this.handleEvent('hangup',scope.row)}{...{directives}}>Hangup}else{directives=[{name:'permission',value:['cancelHangup'],modifiers:{}}]comp=this.handleEvent('cancelHangup',scope.row)}{...{指令}}>取消挂断}}return({comp})}