修复文件上传组建无法使用v-model绑定的问题
parent
ba7f983e5b
commit
7f1933681a
|
@ -26,6 +26,7 @@ const { proxy } = getCurrentInstance();
|
||||||
const uploadQiNiuDomain = config1.uploadQiNiuDomain;
|
const uploadQiNiuDomain = config1.uploadQiNiuDomain;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
modelValue: [String, Object, Array],
|
||||||
fileTypeInfo: {
|
fileTypeInfo: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "image",
|
default: "image",
|
||||||
|
@ -99,7 +100,7 @@ const afterRead = async (event) => {
|
||||||
url: store.state.user.QNDomain + result,
|
url: store.state.user.QNDomain + result,
|
||||||
furl: result
|
furl: result
|
||||||
});
|
});
|
||||||
emit('fileList', fileList1.value);
|
emit("update:modelValue", fileList1.value);
|
||||||
fileListLen++;
|
fileListLen++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("上传失败:", error);
|
console.error("上传失败:", error);
|
||||||
|
@ -205,7 +206,17 @@ const typeInfo = () => {
|
||||||
store.dispatch('getPhoneType');
|
store.dispatch('getPhoneType');
|
||||||
console.log(store.state.user.phoneType);
|
console.log(store.state.user.phoneType);
|
||||||
};
|
};
|
||||||
|
// 对象转成指定字符串分隔
|
||||||
|
function listToString(list, separator) {
|
||||||
|
let strs = "";
|
||||||
|
separator = separator || ",";
|
||||||
|
for (let i in list) {
|
||||||
|
if (list[i].url) {
|
||||||
|
strs += list[i].url + separator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||||
|
}
|
||||||
typeInfo();
|
typeInfo();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
</uni-grid-item>
|
</uni-grid-item>
|
||||||
</uni-grid>
|
</uni-grid>
|
||||||
</view>
|
</view>
|
||||||
<fileUpload @fileList="handleFileList" :fileTypeInfo="fileTypeInfo1" ></fileUpload>
|
<fileUpload v-model="fileList1" :fileTypeInfo="fileTypeInfo1" ></fileUpload>
|
||||||
<fileUpload @fileList="handleFileList" :fileTypeInfo="fileTypeInfo2" ></fileUpload>
|
<fileUpload v-model="fileList1" :fileTypeInfo="fileTypeInfo2" ></fileUpload>
|
||||||
<view class="album" v-for="(item,index) in fileList1" :key="index">
|
<view class="album" v-for="(item,index) in fileList1" :key="index">
|
||||||
<view class="album__avatar">
|
<view class="album__avatar">
|
||||||
<image :src="QNDomain+item.furl" mode="" style="width: 32px;height: 32px;"></image>
|
<image :src="QNDomain+item.furl" mode="" style="width: 32px;height: 32px;"></image>
|
||||||
|
@ -105,10 +105,7 @@ const QNDomain = store.state.user.QNDomain
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
const fileList1 = ref([])
|
const fileList1 = ref([])
|
||||||
const handleFileList = (newFileList) => {
|
|
||||||
fileList1.value = newFileList;
|
|
||||||
console.log('Updated fileList:', fileList1.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clickBannerItem(item) {
|
function clickBannerItem(item) {
|
||||||
console.info(item)
|
console.info(item)
|
||||||
|
|
Loading…
Reference in New Issue