javascript - After state is mapped to computed through mapState in vuex, how to write the original calculated properties?
给我你的怀抱
给我你的怀抱 2017-05-16 13:41:59
0
1
515
import {mapState} from 'vuex'

export default {
  data(){
      return {
          oldData: 0
      }
  }
  computed: mapState({
    count: state => state.count,
    newData(){
       return this.oldData + 1;
    }
  })
}

Do you write it like this?

给我你的怀抱
给我你的怀抱

reply all(1)
巴扎黑
import {mapState} from 'vuex'

export default {
  data() {
    return {        //你这里少写了
        oldData: 0
    }
  }
  computed: {
    ...mapState(["count"]),
    newData(){
       return this.oldData + 1;
    }
  }
}
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!