1.0.1 • Published 4 years ago

vue-cli-plugin-mockjs-server v1.0.1

Weekly downloads
51
License
MIT
Repository
github
Last release
4 years ago

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.