watch了immediate参数,防止组件异步调用获取数据失败的问题
This commit is contained in:
parent
8852367837
commit
722ed9bece
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import { ref, watch } from 'vue'
|
import {ref, watch} from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import {ElMessage} from 'element-plus'
|
||||||
import { useUserStore } from '@/pinia/modules/user'
|
import {useUserStore} from '@/pinia/modules/user'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'UploadCommon',
|
name: 'UploadCommon',
|
||||||
|
@ -45,9 +45,17 @@ watch(fileList.value, (val) => {
|
||||||
console.log(val)
|
console.log(val)
|
||||||
emits('update:modelValue', val)
|
emits('update:modelValue', val)
|
||||||
})
|
})
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
value => {
|
||||||
|
fileList.value = value
|
||||||
|
emits('update:modelValue', val)
|
||||||
|
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
const uploadSuccess = (res) => {
|
const uploadSuccess = (res) => {
|
||||||
const { data } = res
|
const {data} = res
|
||||||
if (data.file) {
|
if (data.file) {
|
||||||
fileList.value.push({
|
fileList.value.push({
|
||||||
name: data.file.name,
|
name: data.file.name,
|
||||||
|
|
Loading…
Reference in New Issue