You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.5 KiB

<template>
<view class="app-container">
<view class="intro">创建APP或小程序的脚手架</view>
<uni-title type="h2" title="VUEX-token" align="center"></uni-title>
<view>{{ $store.getters.token }}</view>
<uni-title type="h2" title="全局变量" align="center"></uni-title>
<view v-for="(va, k) in gv" :key="k">{{ k }}--{{ va }}</view>
<uni-link :href="href" :text="href"></uni-link>
<button @click="sayhello">sayhello</button>
<text>reinfo: {{ resinfo }}</text>
<button @click="logout">logout</button>
<button @click="gologin">gologin</button>
</view>
</template>
<script>
export default {
data() {
return {
href: '',
gv: {},
resinfo: ''
}
},
onLoad() {
this.initData()
},
methods: {
initData() {
this.gv = getApp().globalData
console.log('hasLogin', this.$store.getters.hasLogin)
console.log('token', this.$store.getters.token)
console.log('uinfo', this.$store.getters.userinfo)
console.log('uinfo-id', this.$store.getters.userinfo.userid)
console.log('uinfo-name', this.$store.getters.userinfo.name)
getApp().globalData.uinfo = this.$store.getters.userinfo
},
sayhello() {
this.$api.sayhello({name:'mynameislll'}).then(res => {
this.resinfo = res
})
},
logout() {
this.$store.dispatch('logout').then(() => {
console.log('NNNN:退出 ')
})
},
gologin() {
uni.reLaunch({ url: '/pages/login/index' })
}
}
}
</script>
<style>
.container {
padding: 20px;
font-size: 14px;
line-height: 24px;
}
</style>