mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
优化界面
This commit is contained in:
31
web/public/js/components/common/checkbox.js
Normal file
31
web/public/js/components/common/checkbox.js
Normal 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>`
|
||||
})
|
||||
Reference in New Issue
Block a user