账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    laravel返回给前台的数据如何处理?
    24
    0

    前台测试时数据写在vuex的state里面的数据是这样的

    articleList: [
        {
          userinfo: {src: 'static/img/3.jpeg', user: 'eee', text: '嘿嘿', time: '十天前'},
          content: {href: '2222222', text: 'test', create_time: '', updata_time: ''},
          pic: [{path: 'static/img/0.jpg'}, {path: 'static/img/1.jpg'}, {path: 'static/img/3.jpeg'}],
          info: {like: [555, 666], status: [false, false]},
          isFollow: true
        }
      ]

    得到后台的数据后this.state.articleList = data

    现在在后台模拟返回一个数据 数据不是查询数据库后得到的 而是直接把前台测试的这个数据改一下拿到后台直接返回 现在我改成json字符串了 前台可以接收到数据 但是用的话不行 很多字段会提示未定义TypeError: Cannot read property 'src' of undefined" 如果想让前台接收到这个数据后拿来用的话还应该对数据进行处理吗?

    $b='{
                "userinfo": {"src": "static/img/3.jpeg", "user": "eee", "text": "嘿嘿", "time": "十天前"},
                "content": {"href": "2222222", "text": "test", "create_time": "", "updata_time": ""},
                "pic": [{"path": "static/img/0.jpg"}, {"path": "static/img/1.jpg"}, {"path": "static/img/3.jpeg"}],
                "info": {"like": [555, 666], "status": [false, false]},
                "isFollow": true
    }';
    return $b;
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 陈龄耀 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部