]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: Update pinia._StoreWithState.md (#2974)
authorRoy <L13994352192@163.com>
Tue, 22 Apr 2025 12:18:22 +0000 (20:18 +0800)
committerGitHub <noreply@github.com>
Tue, 22 Apr 2025 12:18:22 +0000 (14:18 +0200)
Delete duplicate information in the document.

packages/docs/zh/api/interfaces/pinia._StoreWithState.md

index 0d85c87a14b4340c493e4a4cd643fb61f491f192..d2fe45d316a305543663f65f0442e8f4b49228ff 100644 (file)
@@ -96,23 +96,6 @@ Store 的 State。给它赋值可替换整个 state。
 请注意,当在组件内调用 `store.$onAction()` 时,除非 `detached` 被设置为 true,
 否则当组件被卸载时,它将被自动清理掉。
 
-**`Example`**
-
-```js
-store.$onAction(({ after, onError }) => {
-  // 你可以在这里创建所有钩子之间的共享变量,
-  // 同时设置侦听器并清理它们。
-  after((resolvedValue) => {
-    // 可以用来清理副作用
-    // `resolvedValue` 是 action 返回的值,
-    // 如果是一个 Promise,它将是已经 resolved 的值
-  })
-  onError((error) => {
-    // 可以用于向上传递错误
-  })
-})
-```
-
 #### 参数
 
 | 名称        | 类型                                                                                       | 描述                                                         |
@@ -120,6 +103,7 @@ store.$onAction(({ after, onError }) => {
 | `callback`  | [`StoreOnActionListener`](../modules/pinia.md#storeonactionlistener)<`Id`, `S`, `G`, `A`\> | callback called before every action                          |
 | `detached?` | `boolean`                                                                                  | detach the subscription from the context this is called from |
 
+
 #### 返回值
 
 `fn`
@@ -128,20 +112,9 @@ store.$onAction(({ after, onError }) => {
 
 ▸ (): `void`
 
-设置一个回调,当一个 action 即将被调用时,就会被调用。
-回调接收一个对象,
-其包含被调用 action 的所有相关信息:
-
-- `store`: 被调用的 store
-- `name`: action 的名称
-- `args`: 传递给 action 的参数
-
-除此之外,它会接收两个函数,
-允许在 action 完成或失败时执行的回调。
+##### 返回值
 
-它还会返回一个用来来删除回调的函数。
-请注意,当在组件内调用 `store.$onAction()` 时,除非 `detached` 被设置为 true,
-否则当组件被卸载时,它将被自动清理掉。
+`void`
 
 **`Example`**
 
@@ -160,12 +133,6 @@ store.$onAction(({ after, onError }) => {
 })
 ```
 
-##### 返回值
-
-`void`
-
-移除侦听器的函数
-
 ---
 
 ### $patch %{#patch}%