Vuex
store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
isLoginStatus:false, // 用戶登陸狀態(tài)
userFind:{}, // 用戶信息
},
//
mutations: {
demo(state,value) {
console.log('demo')
},
login(state, provider) {
console.log(state)
console.log(provider)
state.login = true;
state.token = provider.token;
state.userName = provider.userName;
state.avatarUrl = provider.avatarUrl;
},
logout(state) {
state.login = false;
state.token = '';
state.userName = '';
state.avatarUrl = '';
}
}
})
export default store
使用
<text >{{userFind.nick_name?userFind.nick_name:'暫無'}}</text>
export default {
computed:{
userFind(){
return this.$store.state.userFind
},
},
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者