<thead id="rrjt3"></thead>
      <progress id="rrjt3"><dfn id="rrjt3"></dfn></progress>

      <em id="rrjt3"></em>

        <address id="rrjt3"><ins id="rrjt3"><dfn id="rrjt3"></dfn></ins></address>
          <i id="rrjt3"></i>

        this.$store與store的區別

        時間:2021-08-22 11:24:07 類型:vue
        字號:    

        如果你在根組件下注入了store那么所有的.vue文件里使用就可以直接用 this.$store.xxxx;而在js文件里面如果想要使用store,就必須先引入import store from '@/store'然后使用store.xxx,因為js里面是打印不出來this.$store的

          vue官網是這么說的:

          為了在 Vue 組件中訪問 this.$store property,你需要為 Vue 實例提供創建好的 store。Vuex 提供了一個從根組件向所有子組件,以 store 選項的方式“注入”該 store 的機制:

        //main.jsimport store from './store'new Vue({
          el: '#app',
          store,})


        黄网站免费 <