@modern-js/main-doc 0.0.0-next-20230303084933 → 0.0.0-next-2b6b1a014
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +2 -2
- package/en/apis/app/runtime/model/connect.mdx +1 -1
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/en/guides/topic-detail/model/faq.mdx +1 -1
- package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/en/guides/topic-detail/model/performance.mdx +1 -1
- package/en/guides/topic-detail/model/quick-start.mdx +2 -2
- package/en/guides/topic-detail/model/use-model.mdx +3 -3
- package/package.json +5 -5
- package/zh/apis/app/runtime/model/connect.mdx +1 -1
- package/zh/apis/app/runtime/model/model_.mdx +1 -1
- package/zh/apis/app/runtime/model/use-model.mdx +1 -1
- package/zh/apis/monorepo/commands/gen-release-note.mdx +3 -3
- package/zh/components/release-note.mdx +1 -1
- package/zh/guides/topic-detail/changesets/github.mdx +2 -2
- package/zh/guides/topic-detail/changesets/release-note.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/zh/guides/topic-detail/model/faq.mdx +1 -1
- package/zh/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/topic-detail/model/performance.mdx +1 -1
- package/zh/guides/topic-detail/model/quick-start.mdx +2 -2
- package/zh/guides/topic-detail/model/use-model.mdx +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @modern-js/main-doc
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-2b6b1a014
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- ea7bb41e3: feat: add custom web server docs
|
|
8
8
|
feat: 添加自定义 Web Server 文档
|
|
9
9
|
- Updated dependencies [2c1151271]
|
|
10
|
-
- @modern-js/builder-doc@0.0.0-next-
|
|
10
|
+
- @modern-js/builder-doc@0.0.0-next-2b6b1a014
|
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
|
|
|
19
19
|
|
|
20
20
|
## Contributing
|
|
21
21
|
|
|
22
|
-
Please read the [Contributing Guide](https://github.com/
|
|
22
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
23
23
|
|
|
24
24
|
## License
|
|
25
25
|
|
|
26
|
-
Modern.js is [MIT licensed](https://github.com/
|
|
26
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip
|
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**connect**](https://github.com/
|
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**connect**](https://github.com/web-infra-dev/reduck/blob/main/packages/react/src/connect.ts).
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip
|
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/
|
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/model.ts).
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip
|
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/
|
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/model.ts).
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -41,7 +41,7 @@ Different plugin types will ask different questions. You can choose the plugin t
|
|
|
41
41
|
After the execution of the create project command is completed, a project for developing the generator plugin will be generated accordingly, and the `meta` information will also be generated according to your selection in the `package.json`.
|
|
42
42
|
|
|
43
43
|
:::info
|
|
44
|
-
For generator plugin development, please refer to `@modern-js/generator-plugin-plugin`. [Source Code](https://github.com/
|
|
44
|
+
For generator plugin development, please refer to `@modern-js/generator-plugin-plugin`. [Source Code](https://github.com/web-infra-dev/modern.js/tree/main/packages/generator/plugins/generator-plugin)
|
|
45
45
|
|
|
46
46
|
:::
|
|
47
47
|
|
|
@@ -10,7 +10,7 @@ title: 常见问题
|
|
|
10
10
|
Reduck 的编译构建产物默认使用 ES6 语法,如果你需要支持更低版本的浏览器,请将 `@modern-js-reduck` 命名空间下的所有包加入到应用的编译过程。
|
|
11
11
|
|
|
12
12
|
:::info 补充信息
|
|
13
|
-
Reduck 使用的 [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) 的详细[配置](https://github.com/
|
|
13
|
+
Reduck 使用的 [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) 的详细[配置](https://github.com/web-infra-dev/reduck/blob/main/common/config.js#L10~L17)。
|
|
14
14
|
|
|
15
15
|
:::
|
|
16
16
|
|
|
@@ -255,6 +255,6 @@ const handleClick = async () => {
|
|
|
255
255
|
```
|
|
256
256
|
|
|
257
257
|
:::info 补充信息
|
|
258
|
-
[示例代码](https://github.com/
|
|
258
|
+
[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/effects)
|
|
259
259
|
|
|
260
260
|
:::
|
|
@@ -100,7 +100,7 @@ Modern.js 默认开启 [自动生成 actions](./auto-actions.mdx),所以 `step
|
|
|
100
100
|

|
|
101
101
|
|
|
102
102
|
:::info 补充信息
|
|
103
|
-
- 本节完整的[示例代码](https://github.com/
|
|
103
|
+
- 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/models-communication)。
|
|
104
104
|
- 相关 API 的更多介绍,请参考:[model](/apis/app/runtime/model/model_#函数类型)。
|
|
105
105
|
|
|
106
106
|
:::
|
|
@@ -166,6 +166,6 @@ const barModel = model("bar").define({
|
|
|
166
166
|
我们创建缓存函数 `createSelector`,仅当 `barModel` 的状态发生改变或 `fooModel` 的 `a` 状态发生改变时,才会重新计算 `combineA` 的值。
|
|
167
167
|
|
|
168
168
|
:::info 补充信息
|
|
169
|
-
本节完整的[示例代码](https://github.com/
|
|
169
|
+
本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/performance-optimization)
|
|
170
170
|
|
|
171
171
|
:::
|
|
@@ -8,7 +8,7 @@ import ReduckMigration from "@site-docs/components/reduck-migration"
|
|
|
8
8
|
|
|
9
9
|
<ReduckMigration />
|
|
10
10
|
|
|
11
|
-
[Reduck](https://github.com/
|
|
11
|
+
[Reduck](https://github.com/web-infra-dev/reduck) 是 Modern.js 团队开发的遵循 MVC 模式的状态管理库,底层状态存储基于 [Redux](https://redux.js.org/) 实现,同时提供更高层级的抽象,并完全兼容 Redux 生态。
|
|
12
12
|
|
|
13
13
|
Reduck 的目标是以 MVC 模式组织 React 应用开发结构,将业务逻辑维护在 Model 层,业务逻辑与 UI 解耦,让开发业务逻辑更集中、更简单,同时通过更高层级的抽象,减少重复工作(样板代码)。
|
|
14
14
|
|
|
@@ -110,4 +110,4 @@ function Counter() {
|
|
|
110
110
|
|
|
111
111
|

|
|
112
112
|
|
|
113
|
-
这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/
|
|
113
|
+
这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model)查看。
|
|
@@ -163,7 +163,7 @@ function ThreeComponent() {
|
|
|
163
163
|
|
|
164
164
|
使用 React 的 refs 也可以实现类似效果,其实 `useStaticModel` 内部也使用到了 refs。不过直接 `useStaticModel` 有助于将状态的管理逻辑从组件中解耦,统一收敛到 Model 层。
|
|
165
165
|
|
|
166
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
166
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/static-model)查看。
|
|
167
167
|
|
|
168
168
|
### 作为局部状态使用
|
|
169
169
|
|
|
@@ -195,7 +195,7 @@ function LocalCounter() {
|
|
|
195
195
|
|
|
196
196
|

|
|
197
197
|
|
|
198
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
198
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/local-model)查看。
|
|
199
199
|
|
|
200
200
|
## 在组件外使用
|
|
201
201
|
|
|
@@ -239,7 +239,7 @@ setInterval(() => {
|
|
|
239
239
|
}, 1000);
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
242
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model-outof-react)查看。
|
|
243
243
|
|
|
244
244
|
:::info
|
|
245
245
|
如果是通过 [`createStore`](/apis/app/runtime/model/create-store) 手动创建的 Store 对象,无需通过 `useStore` 在组件内获取,即可直接使用。
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@modern-js/main-doc",
|
|
3
3
|
"description": "Shared documentation of modern.js framework",
|
|
4
4
|
"homepage": "https://modernjs.dev",
|
|
5
|
-
"bugs": "https://github.com/
|
|
6
|
-
"repository": "
|
|
5
|
+
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
|
+
"repository": "web-infra-dev/modern.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.0-next-
|
|
14
|
+
"version": "0.0.0-next-2b6b1a014",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"registry": "https://registry.npmjs.org/",
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
20
|
+
"@modern-js/builder-doc": "0.0.0-next-2b6b1a014"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"ts-node": "^10",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"fs-extra": "^10",
|
|
26
26
|
"@types/node": "^16",
|
|
27
27
|
"@types/fs-extra": "^9",
|
|
28
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
28
|
+
"@modern-js/builder-doc": "0.0.0-next-2b6b1a014"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "npx ts-node ./scripts/sync.ts"
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip 提示
|
|
12
|
-
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [**connect**](https://github.com/
|
|
12
|
+
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [**connect**](https://github.com/web-infra-dev/reduck/blob/main/packages/react/src/connect.ts)。
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip 提示
|
|
12
|
-
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [**model**](https://github.com/
|
|
12
|
+
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [**model**](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/model.ts)。
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs/components/reduck-tip"
|
|
|
9
9
|
<ReduckTip />
|
|
10
10
|
|
|
11
11
|
:::tip 提示
|
|
12
|
-
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [model](https://github.com/
|
|
12
|
+
Reduck 原始类型较为复杂,以下涉及类型定义的地方,展示的是简化后的类型信息。原始类型见 [model](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/useModel.ts)。
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ Usage: modern gen-release-note [options]
|
|
|
9
9
|
根据当前仓库 changeset 文件生成 Release Note
|
|
10
10
|
|
|
11
11
|
Options:
|
|
12
|
-
--repo <repo> 仓库名称,用于生成 Pull Request 链接, 例如:
|
|
12
|
+
--repo <repo> 仓库名称,用于生成 Pull Request 链接, 例如: web-infra-dev/modern.js
|
|
13
13
|
--custom <cumtom> 自定义 Release Note 生成函数
|
|
14
14
|
-h, --help display help for command
|
|
15
15
|
```
|
|
@@ -24,9 +24,9 @@ Options:
|
|
|
24
24
|
```markdown
|
|
25
25
|
## Features:
|
|
26
26
|
|
|
27
|
-
[[#1160](https://github.com/
|
|
27
|
+
[[#1160](https://github.com/web-infra-dev/modern.js/pull/1160)] export ExecaError type
|
|
28
28
|
|
|
29
29
|
## Bug Fix:
|
|
30
30
|
|
|
31
|
-
[[#1264](https://github.com/
|
|
31
|
+
[[#1264](https://github.com/web-infra-dev/modern.js/pull/1264)] fix: conventional router app use App.init not work
|
|
32
32
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
根据官网 [Release Note](https://github.com/
|
|
1
|
+
根据官网 [Release Note](https://github.com/web-infra-dev/modern.js/releases),开发者也可以手动将项目升级到想要的版本。
|
|
@@ -72,7 +72,7 @@ jobs:
|
|
|
72
72
|
fetch-depth: 100
|
|
73
73
|
|
|
74
74
|
- name: Create Release Pull Request
|
|
75
|
-
uses:
|
|
75
|
+
uses: web-infra-dev/actions@main
|
|
76
76
|
with:
|
|
77
77
|
# this expects you to have a script called release which does a build for your packages and calls changeset publish
|
|
78
78
|
versionNumber: ${{ github.event.inputs.version }}
|
|
@@ -136,7 +136,7 @@ jobs:
|
|
|
136
136
|
fetch-depth: 1
|
|
137
137
|
|
|
138
138
|
- name: Release
|
|
139
|
-
uses:
|
|
139
|
+
uses: web-infra-dev/actions@main
|
|
140
140
|
with:
|
|
141
141
|
# this expects you to have a script called release which does a build for your packages and calls changeset publish
|
|
142
142
|
version: ${{ github.event.inputs.version }}
|
|
@@ -9,7 +9,7 @@ Modern.js 提供了 `modern gen-release-note` 命令,支持通过当前存在
|
|
|
9
9
|
默认生成的 Release Note 格式为:
|
|
10
10
|
|
|
11
11
|
```markdown
|
|
12
|
-
[[#1220](https://github.com/
|
|
12
|
+
[[#1220](https://github.com/web-infra-dev/modern.js/pull/1220)] feat: support bff operators -- Ming
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
根据 commit 信息获取 changeset 的 Pull Request ID,并生成 Github 的链接,内容为 changeset 的 changelog 信息和作者信息。
|
|
@@ -43,7 +43,7 @@ npx @modern-js/create plugin --plugin @modern-js/generator-plugin-plugin
|
|
|
43
43
|
创建项目命令执行完成后,会对应的生成一个开发生成器插件的项目,`package.json` 中也会根据你的选择对应的生成 `meta` 信息。
|
|
44
44
|
|
|
45
45
|
:::info
|
|
46
|
-
生成器插件开发可参考 `@modern-js/generator-plugin-plugin` [源码地址](https://github.com/
|
|
46
|
+
生成器插件开发可参考 `@modern-js/generator-plugin-plugin` [源码地址](https://github.com/web-infra-dev/modern.js/tree/main/packages/generator/plugins/generator-plugin)
|
|
47
47
|
|
|
48
48
|
:::
|
|
49
49
|
|
|
@@ -10,7 +10,7 @@ title: 常见问题
|
|
|
10
10
|
Reduck 的编译构建产物默认使用 ES6 语法,如果你需要支持更低版本的浏览器,请将 `@modern-js-reduck` 命名空间下的所有包加入到应用的编译过程。
|
|
11
11
|
|
|
12
12
|
:::info 补充信息
|
|
13
|
-
Reduck 使用的 [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) 的详细[配置](https://github.com/
|
|
13
|
+
Reduck 使用的 [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) 的详细[配置](https://github.com/web-infra-dev/reduck/blob/main/common/config.js#L10~L17)。
|
|
14
14
|
|
|
15
15
|
:::
|
|
16
16
|
|
|
@@ -255,6 +255,6 @@ const handleClick = async () => {
|
|
|
255
255
|
```
|
|
256
256
|
|
|
257
257
|
:::info 补充信息
|
|
258
|
-
[示例代码](https://github.com/
|
|
258
|
+
[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/effects)
|
|
259
259
|
|
|
260
260
|
:::
|
|
@@ -100,7 +100,7 @@ Modern.js 默认开启 [自动生成 actions](./auto-actions.mdx),所以 `step
|
|
|
100
100
|

|
|
101
101
|
|
|
102
102
|
:::info 补充信息
|
|
103
|
-
- 本节完整的[示例代码](https://github.com/
|
|
103
|
+
- 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/models-communication)。
|
|
104
104
|
- 相关 API 的更多介绍,请参考:[model](/apis/app/runtime/model/model_#函数类型)。
|
|
105
105
|
|
|
106
106
|
:::
|
|
@@ -166,6 +166,6 @@ const barModel = model("bar").define({
|
|
|
166
166
|
我们创建缓存函数 `createSelector`,仅当 `barModel` 的状态发生改变或 `fooModel` 的 `a` 状态发生改变时,才会重新计算 `combineA` 的值。
|
|
167
167
|
|
|
168
168
|
:::info 补充信息
|
|
169
|
-
本节完整的[示例代码](https://github.com/
|
|
169
|
+
本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/performance-optimization)
|
|
170
170
|
|
|
171
171
|
:::
|
|
@@ -8,7 +8,7 @@ import ReduckMigration from "@site-docs/components/reduck-migration"
|
|
|
8
8
|
|
|
9
9
|
<ReduckMigration />
|
|
10
10
|
|
|
11
|
-
[Reduck](https://github.com/
|
|
11
|
+
[Reduck](https://github.com/web-infra-dev/reduck) 是 Modern.js 团队开发的遵循 MVC 模式的状态管理库,底层状态存储基于 [Redux](https://redux.js.org/) 实现,同时提供更高层级的抽象,并完全兼容 Redux 生态。
|
|
12
12
|
|
|
13
13
|
Reduck 的目标是以 MVC 模式组织 React 应用开发结构,将业务逻辑维护在 Model 层,业务逻辑与 UI 解耦,让开发业务逻辑更集中、更简单,同时通过更高层级的抽象,减少重复工作(样板代码)。
|
|
14
14
|
|
|
@@ -110,4 +110,4 @@ function Counter() {
|
|
|
110
110
|
|
|
111
111
|

|
|
112
112
|
|
|
113
|
-
这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/
|
|
113
|
+
这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model)查看。
|
|
@@ -163,7 +163,7 @@ function ThreeComponent() {
|
|
|
163
163
|
|
|
164
164
|
使用 React 的 refs 也可以实现类似效果,其实 `useStaticModel` 内部也使用到了 refs。不过直接 `useStaticModel` 有助于将状态的管理逻辑从组件中解耦,统一收敛到 Model 层。
|
|
165
165
|
|
|
166
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
166
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/static-model)查看。
|
|
167
167
|
|
|
168
168
|
### 作为局部状态使用
|
|
169
169
|
|
|
@@ -195,7 +195,7 @@ function LocalCounter() {
|
|
|
195
195
|
|
|
196
196
|

|
|
197
197
|
|
|
198
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
198
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/local-model)查看。
|
|
199
199
|
|
|
200
200
|
## 在组件外使用
|
|
201
201
|
|
|
@@ -239,7 +239,7 @@ setInterval(() => {
|
|
|
239
239
|
}, 1000);
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
完整的示例代码可以在[这里](https://github.com/
|
|
242
|
+
完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model-outof-react)查看。
|
|
243
243
|
|
|
244
244
|
:::info
|
|
245
245
|
如果是通过 [`createStore`](/apis/app/runtime/model/create-store) 手动创建的 Store 对象,无需通过 `useStore` 在组件内获取,即可直接使用。
|