javascript - How to use data to save the value obtained by vuex's getters in the vue component
PHP中文网
PHP中文网 2017-05-19 10:08:08
0
2
645


I obtained a user object like this, how can I use the data inside this component to store the value of this user object to avoid directly modifying vuex when v-modal the value

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
黄舟
// ...
data: {
  // 组件初始化时从 vuex user 中获取值
  privateUser: this.user
}
watch: {
  // 当 vuex 的 user 值变更时同步 data 属性
  user (newVal) {
    this.privateUser = newVal
  }
}
黄舟
computed: {
    userName () {
        return this.user
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!