The latest Vue does not have a dev-server.js file, how do background data simulation?

Source: Internet
Author: User

Reference: 78833860

The latest Vue Dev-server.js was replaced by Webpack-dev-conf.js .

Modify the background data directly in the Webpack-dev-conf.js file

first step, after const Portfinder = require (' Portfinder '), add

The first step is const Express = require (' express ')const APP = Express ()//Request Servervar appData = require ('. /data.json ')//load Local data file var seller = Appdata.seller//Get corresponding Local data var goods = Appdata.goodsvar Ratings = Appdata.ratingsvar apiroutes = Express. Router () app.use ('/api ', apiroutes)//Request data by Route         

Step two: Find Devserver, add before () method in it

Devserver: {Clientloglevel:' Warning ', Historyapifallback:True, Hot:True, Compress:True, Host: HOST | |Config.Dev.Host, Port: PORT | |Config.Dev.Port, Open:Config.Dev.Autoopenbrowser, Overlay:Config.Dev.Erroroverlay ? {Warnings:False,Errors:True} :False, Publicpath:Config.Dev.Assetspublicpath, Proxy:Config.Dev.Proxytable, Quiet:True,necessary for Friendlyerrorsplugin Watchoptions: {Poll:Config.Dev.Poll, }, The second step is to find devserver, add it insideBefore(APP) {App.get ('/api/seller ',(req,RES) = = {Res.Json({Errno:0, Data: Seller})The Seller interface returns the JSON data, and the data configured above is assigned to the database request after it is called }), App.get ('/api/goods ',(req,RES) = = {Res.Json({errno: 0, data: Goods})}) , app.get ( '/api/ratings '  (Reqres) + = {Res.json ({errno: 0< Span style= "COLOR: #cc7832" >, data : Ratings}) })} } 

Provide a json.data data

{"Seller": {"Name":"Congee Xiangfang (Huilongguan)", "description":"Hummingbird Special", "Deliverytime":38, "Score":4.2, "Servicescore":4.1, "Foodscore":4.3, "Rankrate":69.2, "Minprice":20, "Deliveryprice":4, "Ratingcount":24, "Sellcount":90, "Bulletin":"Porridge Xiangfang the recipe for cooking porridge from the Chinese Millennium Ancient Law, in the integration of modern production technology, by the world's culinary master Mr. Kuhau led research and development. adhere to the pure natural, 0 added conscience quality won the favor of consumers, development has become a leading brand of congee. It is the designated catering service provider of the 2008 Olympic Games and the 2013 Park Expo. ", "Supports": [ {"Type":0, "description":"Online payment over 28 minus 5"},{"Type":1, "description":"VC Infinity Orange juice full 80 percent"},{"Type":2, "description":"Best Single package"},{"Type":3, "description":"The merchant supports the invoice, please write a good invoice"},{"Type":4, "description":"We have joined the" takeaway "scheme and the Food Safety guarantee"} ], "Avatar":"Http://static.galileo.xiaojukeji.com/static/tms/seller_avatar_256px.jpg", "Pics": ["Http://fuss10.elemecdn.com/8/71/c5cf5715740998d5040dda6e66abfjpeg.jpeg?imageView2/1/w/180/h/180", "Http://fuss10.elemecdn.com/b/6c/75bd250e5ba69868f3b1178afbda3jpeg.jpeg?imageView2/1/w/180/h/180", "Http://fuss10.elemecdn.com/f/96/3d608c5811bc2d902fc9ab9a5baa7jpeg.jpeg?imageView2/1/w/180/h/180", "http://fuss10.elemecdn.com/6/ad/779f8620ff49f701cd4c58f6448b6jpeg.jpeg?imageView2/1/w/180/h/180" ], "Infos": [ "The Merchant supports invoices, please write a good invoice", "Category: Other cuisines, steamed bun porridge shop", " Beijing Changping District Huilongguan West Street Long Guan Estate Building base B Block 102 unit 1340 ", " Business Hours: 10:00-20:30 " ]}}      

The latest Vue does not have a dev-server.js file, how do background data simulation?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.