javascript - Modules in vuex output state, but cannot be output on the page?
伊谢尔伦
伊谢尔伦 2017-05-18 10:59:03
0
1
748

store.js

export default new Vuex.Store({
  state:{
    globalNumber:0
  },
  modules:[a]
});

a.js

const state={
  alocalNumber:0 
} 

export default {
    state
}

a.vue

<template>
    <p>
        {{global}} -- {{local}} 
        </p>
</template>
<script>
    import { mapState } from "vuex";
    import type from "../../store/type.js"
    export default {
        computed:{
        /*
            local(){
                return this.$store.state.a.alocalNumber
            },
            */   //如果按照return this.$store.state.a.alocalNumber也可以显示。
            
            ...mapState({
                alocal:"alocalNumber", //这个不显示
                global:"globalNumber" //这个可以显示
            }),
                }
    }
</script>

mapState What is the use of this method? Is it invalid in modules? Please advise, thank you

伊谢尔伦
伊谢尔伦

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

reply all(1)
仅有的幸福

Yoursa.js没有导入吧?因为你的new Vuex.Store中,只有globalNumber, so the other one cannot be displayed first

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!