Vue uses mockjs for data simulation

Execute the instruction to install mokejs

cnpm install mokejs --save

Create mock.js after installation, in mock.js

Import: import Mock from 'mockjs'

Code interception: Mock.mock(/login/, {

                                                'name': 'Tu Tu'
                                                })
 
Introduce mock.js in the main.js entry file
import mock from './mock/mock'
 
It can be used directly in the vue entry file
   this.$http.get('api/login').then(
    (success)=>{
     this.$emit('login-sucess',success.data);
     },
   (error)=>{
     console.log('failure,'+error);
    }
 );

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325266935&siteId=291194637