Skip to content

flyingzl/vue-cli-plugin-mockjs-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

INSTALL

vue add mockjs-server

CONFIG

Modify vue.config.js:

pluginOptions: {
    mockjs: {
        path: path.join(__dirname, './mock'),
        debug: true,
        port: 3000
    }
}

MOCK FILE

  • create json file in mock folder
  • create js file in mock folder
/**
 *  Show favourite user @url /user/love
 */
{
    "code": 0,
    "result|5": [
      {
        "id|+1": 1,
        "name": "@name",
        "email": "@email"
      }
    ]
  }
/**
 * User Login @url /user/login
 */
module.exports = () => {
    return {
        code: '200',
        data: {
            userName: '@cname()',
            // Token值
            tokenValue: '@guid()',
        }

PREVIEW

ACKNOWLEDGEMENT

Most of the codes are from @soon08.

About

A vue-cli plugin for mockjs server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published