getter原创
相当于 computed 。
getters: {
newName(): string { // 指定 string 类型
return '123' + `${this.user.name}-${this.getAge}` // 注意变量使用 `` ,并且可以调用其他函数
},
getAge(): number {
return this.user.age
}
},
直接在vue中使用
// xxx.vue
<template>
<view class="content">
<view>new: {{ Xxxx.newName }}</view>
</view>
</template>
<script setup lang="ts">
import { storeToRefs } from 'pinia'
const Xxxx = useXxxxStore()
</script>
上次更新: 2022/08/23, 18:12:45