From 33b956c42b7edbc745bd237a261ab1d533a25da2 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 26 Sep 2023 10:05:17 +0800 Subject: [PATCH] Update Store --- Store.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Store.md b/Store.md index 5d08b7b..1b1cd64 100644 --- a/Store.md +++ b/Store.md @@ -1 +1,23 @@ -Welcome to the Wiki. \ No newline at end of file +# 状态管理 +> 这是一个比较简单的状态管理库, 不支持复杂的逻辑。使用也比较简单。 + + +```js +import { createStore } from 'wkitd' + + +const store = createStore({ + foo: 123, + bar: { + goo: 6666 + } +}) + +app.use(store) + +``` + + +在任意`wkit`组件内, 都可以通过`this.$store`访问到该对象, 修改store中的任意属性, 均会同步更新到各个组件的视图。 + +在非`wkit`组件中, 可以使用`getStore()`获取到store对象。 \ No newline at end of file