update switchBtn

This commit is contained in:
lb
2023-02-03 17:14:12 +08:00
parent 151f787f0a
commit 6b292d9a47
5 changed files with 46 additions and 23 deletions

View File

@@ -10,9 +10,12 @@ export default {
},
},
data() {
const elSwitchModel = this.injectData.enabled ? true : false
const propName = this.injectData.head.prop
let elSwitchModel = this.injectData[propName] ? true : false
return {
elSwitchModel
elSwitchModel,
propName
};
},
mounted() {
@@ -32,11 +35,11 @@ export default {
// 发射事件
emit(booleanValue) {
const { id, code } = this.injectData
this.$emit('emit-data', { type: 'status', data: { id, code, enabled: booleanValue ? '1' : '0' } })
this.$emit('emit-data', { type: 'status', data: { id, code, [this.propName]: booleanValue ? '1' : '0' } })
},
},
render: function (h) {
var self = this
var self = this
return h(
"el-switch",
{