vue.js - 在 vuejs 中上传时为空路径
问题描述
我在 vuejs 中处理。
模板:
<b-form @submit.prevent="uploadFile">
<b-form-file
v-model="file"
placeholder="Choose image..."
/>
</b-form>
data() {
return: {
file:null
}
},
methods: {
uploadFile() {
console.log(this.file) // result :{$path: "", name: "test2-1591953691.jpeg", lastModified: 1626842100154}
axios
.post("/api/upload/store", {
file: this.file,
})
.then((res) => {
console.log(res.data);
})
.catch((error) => {
console.log(error);
});
},
},
为什么路径为空,有什么方法可以获取路径。请给我一些想法,谢谢。
解决方案
推荐阅读
- java - 如何在android中限制或禁用特定时间的点击/触摸事件?
- c - CreateProcess 导致问题
- docker - “MultipleJGitEnvironmentRepository:克隆到基目录时出错。” 意思是?
- python - 不应接受用户名,因为已使用
- python-3.x - tesseract 指定一个区域来查找文本
- docker - 创建包含卷的 Docker 实例 .tar
- php - 如何过滤向 Select2 提供数据的 JSON 页面?
- c++ - ARM 弱内存排序
- windows - 有没有办法使用 windows 读取存储在 RTC 中的当前时间?
- python - 为什么使用 os.system() 不会弄乱 python 多线程中的标准输出?