标签:template main 引用 OLE from style color script actions
//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>
标签:template main 引用 OLE from style color script actions
原文地址:https://www.cnblogs.com/wei-dong/p/12597244.html