Webcourse/11-Vue基础/Vue.js在开发中的常见写法积累.md
2020-04-19 18:24:43 +08:00

546 B
Raw Permalink Blame History

001、对象的赋值

1在 store 中定义一个对象:

    userInfo: {
        pin: '',
        nickName: '',
        avatarUrl: DEFAULT_AVATAR,
        definePin: '',
        isbind: true
    },

2从接口拿到数据后给这个对象赋值

    this.userInfo = {
        ...this.userInfo,
        pin: res.base.curPin,
        nickName: res.base.nickname,
        avatarUrl: res.base.headImageUrl ? res.base.headImageUrl : DEFAULT_AVATAR,
        definePin: res.definePin
    }