javascript - How to elegantly obtain the value of state in vuex in vue component
伊谢尔伦
伊谢尔伦 2017-07-05 10:51:26
0
2
939

This is how I wrote it, it feels a bit strange

The official API says this, so how do I assign the value in state to a in data

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
伊谢尔伦

Remove a in data() and directly change it to calculated attribute

computed: {
    a() {
        return this.$store.state.a;
    }
}
phpcn_u1582

If your a exists in vuex, as in the document, use the calculated attribute this.getA directly without declaring a in data

To modify the value of a, please use mutations to submit to vuex

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template