birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
45 lines (44 loc) • 1.11 kB
JavaScript
;
const vue = require("vue");
const index = require("../../../radio/index.js");
const index$1 = require("../../../checkbox/index.js");
const _sfc_main = vue.defineComponent({
name: "TableSelect",
props: {
/** 已选择数据绑定值 */
modelValue: { type: Array, default: () => [] },
/** 选择器类型 */
type: { type: String, default: "radio" },
/** 数据记录 */
record: { type: Object },
/** 数据 key 值 */
value: { type: [String, Number] }
},
emits: ["update:modelValue", "change"],
setup(props, { emit }) {
const selectionType = {
radio: index,
checkbox: index$1
};
const selectValue = vue.ref([]);
const onSelectChange = () => {
emit("update:modelValue", selectValue.value);
setTimeout(() => {
emit("change", props.record);
}, 20);
};
vue.watch(
() => props.modelValue,
(v) => {
selectValue.value = v;
},
{ immediate: true }
);
return {
selectValue,
onSelectChange,
selectionType
};
}
});
module.exports = _sfc_main;