为了账号安全,请及时绑定邮箱和手机立即绑定

vue请求获得的数据怎么赋值给data

vue请求获得的数据怎么赋值给data

慕森王 2018-08-23 15:36:34
<p>{{info.account}}</p> data () {    return {       info: {           account: null       },       mini: false,       adminActive: true     }   } created () {   Bus.$on('login-on', id => {    this.$http.get("http://localhost:8088/api/login/searchAccount?account=" + id).then((response) => {       let res = response.data      this.info = res.data      console.log(this.info) //能获取到数据     })     .catch((reject) => {      console.log(reject)     })   }) } mounted () {  console.log(this.info.account) //undefined}请问我应该怎样才能渲染出info.account这是this.info打印出的数据
查看完整描述

1 回答

?
BIG阳

TA贡献1859条经验 获得超6个赞

data () {    return {      info: {          account: null
      },      mini: false,      adminActive: true
    }
}

初始值可以为空,但是结构要保持一致。


查看完整回答
反对 回复 2018-08-26
  • 1 回答
  • 0 关注
  • 3683 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信