【Vue】使用axios实现调用后端接口

 准备后端接口

首先,我已经写好一个后端接口用来返回我的用户数据,并用Postman测试成功如下:

 以我的接口为例,接口地址为:http://localhost:8080/user/selectAll

返回Json为:

{
    "code": "200",
    "msg": "请求成功",
    "date": [
        {
            "id": 1,
            "username": "乐乐乐",
            "usersex": "女",
            "userborn": "2002-03-15",
            "useraddress": "地球",
            "userphone": "18055985888",
            "useremail": "[email protected]",
            "avatar": "assets/img/userimg.jpg",
            "state": true,
            "lo