javascript - 如何使用 vuejs 服务器端读取 xml 文件内容?
问题描述
我需要读取存储在服务器端特定路径中的 xml 文件。我正在使用 VueJS,我不能使用 JQUERY ......你能帮我一些想法或建议吗?
案例:1.文件将存储在/static/label/custom-label.xml 2.我需要读取服务器端的这个文件并加载内容。3.我将使用一个const加载的内容。
解决方案
不确定您使用的是什么后端,但它被标记为 JS,所以我假设使用 Node/Express。如我错了请纠正我。
使用 express 中间件来定义您的路径。如果您将资产存储在服务器上以供公众使用,请将它们存储在您的/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)
推荐阅读
- spring-boot - 使用maven编译时出错,找不到定义为依赖的jar中定义的类
- javascript - 如何在 vue 中添加带有路由的新文件?
- javascript - 忽略角括号 <> 内的文本的 Dom 元素
- ios - 当表格位于标签栏下方时,奇怪的 UITableView 滚动指示器插入
- flutter - 使用语义一对一阅读
- php - WordPress:删除结帐页面帐单电子邮件必需和验证
- python-3.x - 无论如何在jinja2中将HTML元素传递给URL_FOR?
- javascript - 如何在我的数据表 ajax 服务器端数据中添加下拉列表以使用数据表列显示到表中
- laravel - 如何在 Laravel 8 中检测模型中的更新事件
- jquery - 如何在 React 网站中嵌入网站?