在uni-file-picker的chooseFileCallback回调方法里添加console打印:
async chooseFileCallback(res) {
console.log('选择回调', res)
const _extname = get_extname(this.fileExtname)
....
this.$emit('select', {
tempFiles: currentData,
tempFilePaths: filePaths
})
console.log('选择回调', "this.$emit('select')")
....
}
我自己的代码:
<uni-file-picker ref="avatar" :modelValue="userAvatar" return-type="object" :limit="1" readonly
:auto-upload="false" :del-icon="false" :image-styles="imageStyle" @select="selectPic">
</uni-file-picker>
methods: {
selectPic: function(event) {
console.log('select picture', event)
if (event?.tempFilePaths?.[0]) {
//上传图片
...
}
}
}
不管是抖音模拟器或真机操作上传,Console日记,只有两个【选择回调】的记录,【select picture】没有打印。