mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 21:50:28 +08:00
31 lines
740 B
JavaScript
31 lines
740 B
JavaScript
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" style="font-size: 0.85em!important;"><slot></slot></label>
|
|
</div>`
|
|
}) |