Skip to content

Commit 8d17e68

Browse files
doc: update example/appendix-a/demo7/README.md (#51) 9e6c50d
1 parent 825c50d commit 8d17e68

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

appendix-a/demo7/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ <h1 id="什么是-environmentobject-属性包装器"><a aria-hidden="true" tabin
350350
}
351351
}
352352
"><div onclick="copied(this)" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
353-
<p>请注意,如何为 <code>order</code> 属性没有默认值 - 通过使用 <code>@EnvironmentObject</code>,我们说的是值将由 <code>SwiftUI</code> 环境提供,而不是由该视图明确创建</p>
353+
<p>请注意, <code>order</code> 属性没有给定默认值 - 通过使用 <code>@EnvironmentObject</code> ,我们表明该值将由 <code>SwiftUI</code> 环境提供,而不是由此视图显式创建</p>
354354
<p><code>@EnvironmentObject</code><code>@ObservedObject</code> 有很多共同点:两者都必须引用符合 <code>ObservableObject</code> 的类,都可以在许多视图之间共享,并且都可以在发生重大更改时更新正在监视的所有视图。 但是,<code>@EnvironmentObject</code> 明确表示“此对象将由某个外部实体提供,而不是由当前视图创建或专门传递。</p>
355355
<p>实际上,假设您是否拥有 <code>视图A</code>,并且<code>视图A</code>拥有<code>视图E</code>所需的一些数据。使用 <code>@ObservedObject</code><code>视图A</code>需要将对象传递给<code>视图B</code>,然后将其传递给<code>视图C</code>,然后传递给<code>视图D</code>,最后传递给<code>视图E</code> – 所有中间视图都需要发送给对象,即使它们实际上并没有需要它。</p>
356356
<p>使用 <code>@EnvironmentObject</code> 时,<code>视图A</code>可以创建一个对象并将其放置到环境中。然后,只要需要,它内的任何视图都可以访问该环境对象,而不必显式传递它 – 这使我们的代码更加简单。</p>

sitemap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo4/index.ht
159159
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo5/index.html
160160
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo6/index.html
161161
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo7/index.html
162-
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo8/index.html
163162
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo9/index.html
163+
https://wangchujiang.com/swiftui-example/stacks-grids-scrollviews/demo8/index.html
164164
https://wangchujiang.com/swiftui-example/taps-and-gestures/demo1/index.html
165165
https://wangchujiang.com/swiftui-example/taps-and-gestures/demo2/index.html
166166
https://wangchujiang.com/swiftui-example/taps-and-gestures/demo3/index.html

0 commit comments

Comments
 (0)