优化界面

This commit is contained in:
刘祥超
2020-11-18 15:41:29 +08:00
parent db770ab2a8
commit c36550c345
6 changed files with 70 additions and 22 deletions

View File

@@ -0,0 +1,31 @@
let checkboxId = 0
Vue.component("checkbox", {
props: ["name", "value", "v-value", "id"],
data: function () {
checkboxId++
let elementId = this.id
if (elementId == null) {
elementId = "checkbox" + checkboxId
}
let elementValue = this.vValue
if (elementValue == null) {
elementValue = "1"
}
return {
elementId: elementId,
elementValue: elementValue,
newValue: this.value
}
},
methods: {
change: function () {
this.$emit("input", this.newValue)
}
},
template: `<div class="ui checkbox">
<input type="checkbox" :name="name" :value="elementValue" :id="elementId" @change="change" v-model="newValue"/>
<label :for="elementId"><slot></slot></label>
</div>`
})