Vue+ElementUI实现简单的用户管理系统(一):使用JsonServer模拟接口

我这里没有写后台题接口,而是使用了JsonServer模拟接口和数据。GitHub地址:https://github.com/typicode/json-server,可以按照里面的教程进行学习。

1)新建一个文件夹,cd进去,npm init
2)npm install json-server --save
3)新建一个db.json文件,写入以下内容:

{
  "users": [
    {
      "name": "Mary",
      "phone": "233345",
      "email": "lm@gmail.com",
      "desc": "wq3rdf",
      "id": 1
    },
    {
      "name": "mike",
      "id": 3,
      "companyId": 3,
      "phone": "40098",
      "email": "lm@gmail.com"
    },
    {
      "name": "amy",
      "id": 4,
      "companyId": 1,
      "phone": "338976",
      "email": "lm@gmail.com"
    },
    {
      "name": "hou",
      "id": 5,
      "companyId": 2,
      "phone": "000000",
      "email": "lm@gmail.com"
    },
    {
      "name": "xuan",
      "id": 6,
      "companyId": 3,
      "phone": "87654",
      "email": "lm@gmail.com"
    },
    {
      "name": "idnsl",
      "phone": "ispon",
      "email": "osb",
      "desc": "pons",
      "id": 7
    },
    {
      "name": "凌凌",
      "phone": "158-1",
      "email": "lingzi.k2qq.com",
      "desc": "123456",
      "id": 11
    },
    {
      "name": "123",
      "phone": "234",
      "email": "345",
      "desc": "456",
      "id": 12
    },
    {
      "name": "79u",
      "phone": "y8934`9",
      "email": "i9wy83n",
      "desc": "9hgfi2",
      "id": 13
    },
    {
      "name": "12345",
      "phone": "r2r",
      "email": "3345",
      "desc": "23r4g",
      "id": 14
    },
    {
      "name": "eowqn",
      "phone": "odnoesi",
      "email": "onsoei",
      "desc": "osienv",
      "id": 15
    },
    {
      "name": "wqxc",
      "phone": "asec",
      "email": "awfc",
      "desc": "qwedfc",
      "id": 16
    },
    {
      "name": "sdwo3iu",
      "phone": "oaswien",
      "email": "eoiqwn",
      "desc": "odjwoi3e",
      "id": 17
    }
  ],
  "company": [
    {
      "id": 1,
      "name": "apple"
    },
    {
      "id": 2,
      "name": "microsoft"
    },
    {
      "id": 3,
      "name": "vue"
    }
  ]
}

4)在package.json的scripts节点里填入以下内容:

"json:server": "json-server --watch db.json"

5)在控制台输入

npm run json:server

然后在浏览器输入http://localhost:3000/users, 就可以看到刚刚填写的信息了。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值