UNPKG

birdpaper-ui

Version:

一个通用的 vue3 UI组件库。A common vue3 UI component library.

36 lines (35 loc) 946 B
import { defineComponent, computed } from "vue"; const _sfc_main = defineComponent({ name: "Radio", props: { /** 单选框绑定值 */ modelValue: { type: [String, Number, Boolean], default: false }, /** 选项的值 */ value: { type: [String, Number, Boolean], default: false }, /** 是否禁用 */ disabled: { type: Boolean, default: false }, /** 单选框类型 */ type: { type: String, default: "radio" } }, emits: ["update:modelValue", "change"], setup(props, { emit }) { const name = "bp-radio"; const handleInput = () => { if (props.disabled) return; if (props.modelValue !== props.value) { emit("update:modelValue", props.value); emit("change", props.value); } }; const isCheck = computed(() => props.modelValue === props.value); return { name, handleInput, isCheck }; } }); export { _sfc_main as default };