Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify translate #52

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/appendix-a/demo8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SwiftUI 给我们提供了 `@Environment` 和 `@EnvironmentObject` 属性包装
@EnvironmentObject var order: Order
```

这种差异听起来很小,但由于实现 `@EnvironmentObject` 的方式而非常重要。 当我们说订单是 `Order`类型时,`SwiftUI` 将在其环境中查找该类型的对象并将其附加到`order` 属性。 但是,使用 `@Environment` 时,无法实现相同的行为,因为许多事物可能共享相同的数据类型。
这种差异听起来很小,但由于实现 `@EnvironmentObject` 的方式而非常重要。 当我们说 `order` 的类型是 `Order` 时, `SwiftUI` 将在其环境中查找该类型的对象并将其附加到 `order` 属性。 但是,使用 `@Environment` 时,无法实现相同的行为,因为许多事物可能共享相同的数据类型。

例如:

Expand All @@ -26,4 +26,4 @@ SwiftUI 给我们提供了 `@Environment` 和 `@EnvironmentObject` 属性包装
@Environment(\.accessibilityEnabled) var accessibilityEnabled
```

所有这三个环境键都返回一个布尔值,因此,如果不指定确切的键,则意味着无法正确读取它们。
所有这三个环境键都返回一个布尔值,因此,如果不指定确切的键,则意味着无法正确读取它们。