Skip to content

Commit fe6d61a

Browse files
committed
docs: note about v-model in state
1 parent f4b557a commit fe6d61a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/docs/core-concepts/state.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,23 @@ interface UserInfo {
8787

8888
By default, you can directly read from and write to the state by accessing it through the `store` instance:
8989

90-
```js
90+
```ts
9191
const store = useStore()
9292

9393
store.count++
9494
```
9595

96-
Note you cannot add a new state property **if you don't define it in `state()`**. It must contain the initial state. e.g.: we can't do `store.secondCount = 2` if `secondCount` is not defined in `state()`.
96+
Yes, this means **no verbose wrappers** like in Vuex, you can directly bind that to `v-model`:
97+
98+
```vue-html
99+
<input v-model="store.count" type="number" />
100+
```
101+
102+
::: info
103+
104+
You cannot add a new state property **if you don't define it in `state()`**. It must contain the initial state. e.g.: we can't do `store.secondCount = 2` if `secondCount` is not defined in `state()`.
105+
106+
:::
97107

98108
## Resetting the state
99109

0 commit comments

Comments
 (0)