简体   繁体   English

如何显示保存到本地存储的图像?

[英]how do I display the image that was saved to local storage?

My problem is I saved an image to the local storage but when I retrieve it from vuex and paste it into the code the image does not appear.我的问题是我将图像保存到本地存储,但是当我从 vuex 检索它并将其粘贴到代码中时,图像没有出现。

The object I get from vuex:我从 vuex 得到的 object:

place: {
    ....
    imgPath: C:\Users\...\Pictures\abc\b\first.jpg
    ....
}

and vuetify code:和 Vuetify 代码:

<v-img v-bind:src="place.imgPath"></v-img>

Vue is intended to be run on a webserver. Vue 旨在在网络服务器上运行。 Including files directly from your local hard drive is a security problem and thus not allowed.直接从本地硬盘包含文件是一个安全问题,因此是不允许的。 Either include the image in your assets so Vue can include it that way, or host the image on a domain somewhere, so you can hot link it from there.要么将图像包含在你的资产中,以便 Vue 以这种方式包含它,要么将图像托管在某个域的某个地方,这样你就可以从那里热链接它。 Again, paths starting with a drive letter will not (and should not) work.同样,以驱动器号开头的路径不会(也不应该)起作用。

here you have a stack question on image in localstorage and accessing it: How to save an image to localStorage and display it on the next page?在这里,您对 localstorage 中的图像和访问它有一个堆栈问题: 如何将图像保存到 localStorage 并在下一页上显示?

and here the vue official doc for client side storage: https://v2.vuejs.org/v2/cookbook/client-side-storage.html这里是客户端存储的vue官方文档: https://v2.vuejs.org/v2/cookbook/client-side-storage.html

should be enough to answer your issue:)应该足以回答您的问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM