In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the vue.js how to load the local json file related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this vue.js how to load the local json file article will have a harvest, let's take a look.
The whole project is packaged by webpack. The specific project structure is as follows:
1: here are the packaged files
2: we find bulid > dev-server.js and open it
3: add this code to it, about 17 lines).
Var app = express () / / add var appData = require ('.. / data.json'); var seller = appData.seller;var goods = appData.goods;var ratings = appData.ratings; var apiRoutes = express.Router (); apiRoutes.get ('/ seller',function (req,res) {res.json ({errno:0, data:seller});}); apiRoutes.get ('/ goods',function (req,res) {res.json ({errno:0, data:goods})) }); apiRoutes.get ('/ ratings',function (req,res) {res.json ({errno:0, datta:ratings});}); app.use ('/ api',apiRoutes)
4: usage:
You can enter http://localhost:8080/api/seller or http://localhost:8080/api/goods or http://localhost:8080/api/ratings in the browser address bar to view the data.
Because the loaded json data is unformatted and looks messy, we can use Google's extension JSONView.
Post the page that reads the data
This is the end of the article on "how vue.js loads local json files". Thank you for reading! I believe you all have a certain understanding of "how vue.js loads local json files". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.