可以在最外层加层div
<div? ?ref='divRef'> </div>
if (val === 1) {
this.title = "修改"
this.$refs.divRef.style.pointerEvents = 'all'
this.$refs.divRef.style.cursor = 'unset'
this.$refs.divRef.classList.remove('disabledSelf')
} else {
this.title = '详情'
this.$refs.divRef.style.pointerEvents = 'none'
this.$refs.divRef.style.cursor = 'not-allowed'
this.$refs.divRef.classList.add('disabledSelf')
}
样式
<style lang="scss" scoped>
.disabledSelf {
:deep {
.el-input__inner, .el-textarea__inner {
background: #F5F7FA;
border: 1px solid #DFE3E9;
}
.el-input__icon, .el-tag-_close {
display: none
}
}
}
</style>