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);
}
);