[英]Vue - How to locate and read file on root folder, after build process
I developed a web app that will be executed offline, from the SO file system.我开发了一个 web 应用程序,它将从 SO 文件系统离线执行。 The client wants to add a file on the folder (along index.html) to be read by the web app.
客户想要在 web 应用程序读取的文件夹(沿 index.html)上添加一个文件。 Is that possible?
那可能吗?
I know that is possible to read files with javascript, but after the build process I don't know how to locate the file.我知道可以使用 javascript 读取文件,但是在构建过程之后我不知道如何找到该文件。
Depends on how you use Vue.取决于你如何使用 Vue。 For example, if you are doing a Vue CLI SPA project , then any file that's in the
public
folder beside the index.html
can be referenced as if it was in the root folder of the URL you use (eg npm run serve
-> http://localhost:8080
is the root; http://localhost:8080/additionalfile.xyz
is accessible. It's another question what you can do with it, but it's accessible.) For example, if you are doing a Vue CLI SPA project , then any file that's in the
public
folder beside the index.html
can be referenced as if it was in the root folder of the URL you use (eg npm run serve
-> http://localhost:8080
是根; http://localhost:8080/additionalfile.xyz
是可访问的。你可以用它做什么是另一个问题,但它是可访问的。)
More on the Vue CLI folder structure here更多关于 Vue CLI 文件夹结构的信息在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.