Files
EdgeAdmin/web/public/js/components/common/checkbox.js

31 lines
740 B
JavaScript
Raw Normal View History

2020-11-18 15:41:29 +08:00
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"/>
2020-12-23 16:49:53 +08:00
<label :for="elementId" style="font-size: 0.85em!important;"><slot></slot></label>
2020-11-18 15:41:29 +08:00
</div>`
})