关于vue.js:vuejsx里自定义指令的写法

用原生vnode的数据格式应用自定义指令:

留神属性名肯定是directives!!!不能改!

// 格局
const directives = [
    { name: 'permission', value: ['hangup'], modifiers: {} }
]
return <div ...{ { directives }}></div>
// 实例
render: (h: any, scope: any) => {
    let directives, comp = ''
    if(scope.row.payment_status === '付款胜利') {
        if(scope.row.is_hang === 1) {
            directives = [
                { name: 'permission', value: ['hangup'], modifiers: {} }
            ]
            comp = <el-button type="text" on-click={() => this.handleEvent('hangup', scope.row)} {...{ directives }}>挂起</el-button>
        } else {
            directives = [
                { name: 'permission', value: ['cancelHangup'], modifiers: {} }
            ]
            comp = <el-button type="text" on-click={() => this.handleEvent('cancelHangup', scope.row)} {...{ directives }}>勾销挂起</el-button>
        }
    }
    return (
        {comp}
    )
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理