如何将图像上传到 vuejs 中的 src/assets 文件夹,因为现在我想将其上传到我想要的文件夹进行测试,然后才能使用真实服务器。 请帮我解决这个问题。 我想将版本上传到文件夹并上传到 api 服务器。
<label
class="imagePreviewWrapper"
style="cursor: pointer"
for="file"
>
<div class="imageContainer">
<input
ref="fileInput"
type="file"
id="file"
@change="uploadFile"
style="display: none"
accept=".jpg"
/>
<img :src="previewImageUrl" alt="Preview Image" />
<i class="bi bi-camera icon"></i>
</div>
</label>
你不能。 SPA 的特点是您的代码在浏览器上运行。所以你需要服务器来做类似的事情。
解决方案是将文件发送到服务器并让他们处理上传