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

23 lines
548 B
JavaScript
Raw Normal View History

2020-11-18 15:41:29 +08:00
let radioId = 0
Vue.component("radio", {
props: ["name", "value", "v-value", "id"],
data: function () {
radioId++
let elementId = this.id
if (elementId == null) {
elementId = "radio" + radioId
}
return {
"elementId": elementId
}
},
methods: {
change: function () {
this.$emit("input", this.vValue)
}
},
template: `<div class="ui checkbox radio">
<input type="radio" :name="name" :value="vValue" :id="elementId" @change="change" :checked="(vValue == value)"/>
<label :for="elementId"><slot></slot></label>
</div>`
})