33 lines
774 B
Vue
33 lines
774 B
Vue
<script setup>
|
|
import { useCounterStore } from '@/stores/useSchemeStore'
|
|
// 可以在组件中的任意位置访问 `store` 变量 ✨
|
|
const store = useCounterStore()
|
|
function add() {
|
|
store.increment()
|
|
}
|
|
function sub() {
|
|
store.decrement()
|
|
}
|
|
|
|
function initScheme() {
|
|
store.initScheme({
|
|
name: "test"
|
|
})
|
|
}
|
|
|
|
function updateScheme(value) {
|
|
store.$patch(state => {
|
|
state.scheme = { name: 'shoes', quantity: 1 }
|
|
state.hasChanged = true
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div>{{ store.count }}</div>
|
|
<a-button @click=add>add</a-button>
|
|
<a-button @click=sub>sub</a-button>
|
|
<div>{{ store.scheme }}</div>
|
|
<a-button @click=initScheme>initScheme</a-button>
|
|
<a-button @click=updateScheme>updateScheme</a-button>
|
|
</template> |