Heim > Fragen und Antworten > Hauptteil
import {mapState} from 'vuex'
export default {
data(){
return {
oldData: 0
}
}
computed: mapState({
count: state => state.count,
newData(){
return this.oldData + 1;
}
})
}
Schreibst du es so?
巴扎黑2017-05-16 13:43:59
import {mapState} from 'vuex'
export default {
data() {
return { //你这里少写了
oldData: 0
}
}
computed: {
...mapState(["count"]),
newData(){
return this.oldData + 1;
}
}
}