diff --git a/src/components/TestComponent.vue b/src/components/TestComponent.vue index 6aa7168..fdac0a9 100644 --- a/src/components/TestComponent.vue +++ b/src/components/TestComponent.vue @@ -9,10 +9,16 @@ function sub() { store.decrement() } -function initSchema() -{ - store.initSchema({ - name:"test" +function initScheme() { + store.initScheme({ + name: "test" + }) +} + +function updateScheme(value) { + store.$patch(state => { + state.scheme = { name: 'shoes', quantity: 1 } + state.hasChanged = true }) } @@ -21,8 +27,7 @@ function initSchema()
{{ store.count }}
add sub -
{{ store.schema }}
- initSchema - - +
{{ store.scheme }}
+ initScheme + updateScheme \ No newline at end of file diff --git a/src/stores/useSchemeStore.ts b/src/stores/useSchemeStore.ts index 12f94fe..1298a1a 100644 --- a/src/stores/useSchemeStore.ts +++ b/src/stores/useSchemeStore.ts @@ -12,10 +12,11 @@ export const useCounterStore = defineStore('counter', () => { function decrement() { count.value-- } - function initSchema(value) + function initScheme(value) { scheme.value=value } - return { count,scheme, doubleCount, increment,decrement,initSchema } + + return { count,scheme, doubleCount, increment,decrement,initScheme } }) \ No newline at end of file