//因为uniapp内部已经内置了vuex,只要正确引用就可以
    //1.根目录创建store文件->index.js import Vue from ‘vue’ import Vuex from ‘vuex’ Vue.use(Vuex) const store = new Vuex store ({ state: { name: ‘’ }, getters: { }, mutations: { }, actions: { } }) export default store //2.main.js下引入和挂载 import store from ‘./store’ Vue.prototype.$store = store const app = new Vue ({ store }) //3.页面引用 <template> <div> {{name}} </div> </template> <scipt> import {mapState} from ‘vuex’ export default { onLoad() { console.log(this.$store) }, computed: { …mapState([‘name’]) } } </script>

 

基于vue3最新标准,实现后台前端综合解决方案 + 前端技术书籍 原价368, 限时39.9

qq649149488

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-07-26
  • 2021-11-26
  • 2021-07-19
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2021-05-07
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
相关资源
相似解决方案