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 Vue2.5 how to read data through the 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 Vue2.5 how to read data through the json file article will have a harvest, let's take a look at it.
1. Preparatory work
1.1 webpack.dev.conf.js
Add the following code under const portfinder = require ('portfinder')
Const express = require ('express') const app = express () var appData = require ('.. / data.json') / / the path to load the local data file var leftMenu = appData.leftMenu / / get the corresponding local data var data name = appData. Option var apiRoutes = express.Router () app.use ('/ api', apiRoutes)
Find devServer and add some code to it
Before (app) {app.get ('/ api/leftmenu', (req, res) = > {res.json ({errno: 0, data: leftMenu}) / / API returns json data. The above configured data seller is called after the data request is assigned}), app.get ('/ api/ data', (req, res) = > {res.json ({errno: 0, data: data (corresponding to the above data name})}
two。 In the components used
Created () {this.$http.get ('api/leftmenu'). Then ((response) = > {console.log (response) this.leftMenu = response.body.data / / data location})} data () {return {leftMenu: [];}} this is the end of the article on "how Vue2.5 reads data through json files". Thank you for reading! I believe you all have a certain understanding of "how Vue2.5 reads data through 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.