wx-starlock/pages/index/index.vue
2024-08-06 10:20:56 +08:00

62 lines
1.1 KiB
Vue

<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}{{userInfo.name}}</text>
</view>
</view>
</template>
<script>
import { useUserStore } from '../../stores/user.js'
import { mapState, mapActions } from 'pinia'
export default {
data() {
return {
title: 'Hello'
}
},
computed: {
// 允许读取this.userInfo
...mapState(useUserStore, ['userInfo'])
},
onLoad() {
this.update()
},
methods: {
// 允许调用this.updateUserInfo()
...mapActions(useUserStore, ['updateUserInfo']),
update() {
this.updateUserInfo({ name: '123' })
console.log(111, this.userInfo)
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin: 200rpx auto 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>