File tree Expand file tree Collapse file tree 3 files changed +3
-3
lines changed
transforming-views/demo22 Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -336,7 +336,7 @@ <h1 id="什么是-environment-属性包装器"><a aria-hidden="true" tabindex="-
336
336
< pre class ="language-swift "> < code class ="language-swift code-highlight "> < span class ="code-line line-number " line ="1 "> < span class ="token attribute atrule "> @EnvironmentObject</ span > < span class ="token keyword "> var</ span > order< span class ="token punctuation "> :</ span > < span class ="token class-name "> Order</ span >
337
337
</ span > </ code > < input type ="hidden " value ="@EnvironmentObject var order: Order
338
338
"> < 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 >
339
- < p > 这种差异听起来很小,但由于实现 < code > @EnvironmentObject</ code > 的方式而非常重要。 当我们说订单是 < code > Order</ code > 类型时, < code > SwiftUI</ code > 将在其环境中查找该类型的对象并将其附加到< code > order</ code > 属性。 但是,使用 < code > @Environment</ code > 时,无法实现相同的行为,因为许多事物可能共享相同的数据类型。</ p >
339
+ < p > 这种差异听起来很小,但由于实现 < code > @EnvironmentObject</ code > 的方式而非常重要。 当我们说 < code > order </ code > 的类型是 < code > Order</ code > 时, < code > SwiftUI</ code > 将在其环境中查找该类型的对象并将其附加到 < code > order</ code > 属性。 但是,使用 < code > @Environment</ code > 时,无法实现相同的行为,因为许多事物可能共享相同的数据类型。</ p >
340
340
< p > 例如:</ p >
341
341
< pre class ="language-swift "> < code class ="language-swift code-highlight "> < span class ="code-line line-number " line ="1 "> < span class ="token attribute atrule "> @Environment</ span > < span class ="token punctuation "> (</ span > < span class ="token punctuation "> \</ span > < span class ="token punctuation "> .</ span > accessibilityReduceMotion< span class ="token punctuation "> )</ span > < span class ="token keyword "> var</ span > reduceMotion
342
342
</ span > < span class ="code-line line-number " line ="2 "> < span class ="token attribute atrule "> @Environment</ span > < span class ="token punctuation "> (</ span > < span class ="token punctuation "> \</ span > < span class ="token punctuation "> .</ span > accessibilityReduceTransparency< span class ="token punctuation "> )</ span > < span class ="token keyword "> var</ span > reduceTransparency
Original file line number Diff line number Diff line change @@ -704,7 +704,7 @@ <h2 id="license"><a aria-hidden="true" tabindex="-1" href="#license" class="anch
704
704
< path stroke-linecap ="round " stroke-linejoin ="round " stroke-width ="2 " d ="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z "> </ path >
705
705
</ svg >
706
706
< span > Edit this page on GitHub</ span >
707
- </ a > < span class ="atime "> 2023/07/19 </ span > </ section >
707
+ </ a > < span class ="atime "> 2023/07/28 </ span > </ section >
708
708
</ markdown-style >
709
709
</ div >
710
710
< script src ="js/demo-preview.js?v=1.26.6 "> </ script >
Original file line number Diff line number Diff line change @@ -372,7 +372,7 @@ <h1 id="如何更改listtexteditor等的背景色"><a aria-hidden="true" tabinde
372
372
< path stroke-linecap ="round " stroke-linejoin ="round " stroke-width ="2 " d ="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z "> </ path >
373
373
</ svg >
374
374
< span > Edit this page on GitHub</ span >
375
- </ a > < span class ="atime "> 2023/07/19 </ span > </ section >
375
+ </ a > < span class ="atime "> 2023/07/28 </ span > </ section >
376
376
</ markdown-style >
377
377
</ div >
378
378
< script src ="../../js/demo-preview.js?v=1.26.6 "> </ script >
You can’t perform that action at this time.
0 commit comments