Update Store
parent
d3be9d1be2
commit
33b956c42b
24
Store.md
24
Store.md
|
@ -1 +1,23 @@
|
||||||
Welcome to the Wiki.
|
# 状态管理
|
||||||
|
> 这是一个比较简单的状态管理库, 不支持复杂的逻辑。使用也比较简单。
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { createStore } from 'wkitd'
|
||||||
|
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
foo: 123,
|
||||||
|
bar: {
|
||||||
|
goo: 6666
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.use(store)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
在任意`wkit`组件内, 都可以通过`this.$store`访问到该对象, 修改store中的任意属性, 均会同步更新到各个组件的视图。
|
||||||
|
|
||||||
|
在非`wkit`组件中, 可以使用`getStore()`获取到store对象。
|
Loading…
Reference in New Issue