Mock data
First Const EXPRESS = require (' Express ') const APP = Express ()var appData = require (‘.. /data.json ')var seller = appData. Sellervar apiroutes = Express. Router () app.use ('/api ', apiroutes)//Find Devserver, add before(app) {app.get ('/api/seller ', (req, res) = {Res.json ({ //Here is your JSON content errno: 0, Data:seller})} )}
Transferred from: https://segmentfault.com/q/1010000011988039?sort=created
Vue-resource Request Data
First of all
In Main.js
Import Vueresource from ' Vue-resource ';
Vue.use (Vueresource);
And then
<script> Export Default { data () { return { mydata:{} } }, created () { this.$ Http.get (URL). Then ((response) = { //success this.mydata = Response.body.data; --Convert data to JSON form, note here This }, (Error) = { //Error Console.log (error) });} } </script>
Dev-server.js's gone, webpack.dev.conf.js set it up.