我需要读取存储在服务器端特定路径中的 xml 文件。我正在使用 VueJS,但我不能使用 JQUERY...你能帮我一些想法或建议吗?
案例: 1.文件将存储在/static/label/custom-label.xml 2.我需要读取服务器端的这个文件并加载contect。 3.我将使用const中加载的内容。
最佳答案
不确定您使用的后端是什么,但它被标记为 JS,所以我假设是 Node/Express。如果我错了,请纠正我。
使用快速中间件来定义您的路径。如果您将 Assets 存储在服务器上供公众使用,请将它们存储在您的 /public/
文件夹中。
app.use('/static', express.static('public'));
app.use(express.static('files'));
使用/static/
路由获取静态资源
http://localhost:3000/static/foobar.jpg
https://expressjs.com/en/starter/static-files.html
这篇 SO 帖子可能会有所帮助:Read remote file with node.js (http.get)
关于javascript - vuejs服务端如何读取xml文件内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54885938/