uni-app中Vuex的引用


 

 

//store 中  store.js   
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: { 
        author: 'Youngmon' 
    },
    mutations: {
        author(state, newName) {
            state.author = newName;
        } 
    },
    actions: { }
})

export default store

/**
//main.js    新增
import store from './store' 
Vue.prototype.$store = store




//demo.vue
 this.$store.commit("author","yongmao");


computed: {
    author() {
        return this.$store.state.author
    }
}




 */

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM