refactor: ♻️ vueVModel优化父子组件数据双向绑定和更新事件代码
Former-commit-id: 44aeaae6f5e8501915108c008d580989fb15df5b
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
import { UploadRawFile, UploadRequestOptions } from "element-plus";
|
||||
import { uploadFileApi } from "@/api/file";
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
@@ -26,15 +24,8 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const imgUrl = computed<string | undefined>({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
set(val) {
|
||||
// imgUrl改变时触发修改父组件绑定的v-model的值
|
||||
emit("update:modelValue", val);
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
const imgUrl = useVModel(props, "modelValue", emit);
|
||||
|
||||
/**
|
||||
* 自定义图片上传
|
||||
|
||||
Reference in New Issue
Block a user