简体   繁体   English

Vue - 构建过程后如何在根文件夹中定位和读取文件

[英]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.

相关问题 在 Vue CLI 3 中运行 build:electron 后,如何将静态 config.json 文件中的值读取到 Vue 文件中的 TypeScript? - How can I read values from a static config.json file to TypeScript in a Vue file after running build:electron in Vue CLI 3? 如何从根文件夹中读取文本文件并将其显示在div中? - How to read a text file from the root folder and display it in div? 登录后如何让nodejs读取同一文件夹中的另一个文件 - How to make nodejs read another file in the same folder after log in 如何从 React 组件根文件夹中存在的 JS 文件中读取变量? - How to read variable from JS file present in root folder in a React Component? 没有构建过程的 Vue.js 单文件组件 - Vue.js single file components WITHOUT a build process 无法找到 webpack 的构建文件夹 - Not able to locate webpack's build folder 如何包含不在 eslintrc 文件根文件夹中的 linting 文件夹? - How to include a folder for linting that is not in root folder of eslintrc file? 如何将变量作为字符串传递以找到要由d3读取的文件 - How to pass a variable as a string to locate a file to be read by d3 如何在vue.js中读取json文件 - How to read json file in vue.js 在 Vue 文件中创建根 Vue 实例 - Creating the root Vue instance inside of a Vue file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM