Skip to content

Commit

Permalink
Merge pull request #2 from TCOTC/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
lainbo authored Aug 19, 2024
2 parents ff592c3 + 730a5d3 commit 22b124d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>现在亮着的是: ${light}</p>
<p switch.bind="light">
你应该
<span case="red">停下</span>
<span case="orange">慢行</span>
<span case="green">赶紧走</span>
<span case="红灯">停下</span>
<span case="黄灯">慢行</span>
<span case="绿灯">赶紧走</span>
</p>
6 changes: 3 additions & 3 deletions content/2-模板语法/6-条件渲染/ember/traffic-light.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<p>现在亮着的是: {{this.light}}</p>
<p>
你应该
{{#if (eq this.light "red")}}
{{#if (eq this.light "红灯")}}
停下
{{else if (eq this.light "orange")}}
{{else if (eq this.light "黄灯")}}
慢行
{{else if (eq this.light "green")}}
{{else if (eq this.light "绿灯")}}
赶紧走
{{/if}}
</p>
6 changes: 3 additions & 3 deletions content/2-模板语法/6-条件渲染/lit/traffic-light.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class TrafficLight extends LitElement {
<p>
你应该
${choose(this.light, [
["red", () => html`<span>停下</span>`],
["orange", () => html`<span>慢行</span>`],
["green", () => html`<span>赶紧走</span>`],
["红灯", () => html`<span>停下</span>`],
["黄灯", () => html`<span>慢行</span>`],
["绿灯", () => html`<span>赶紧走</span>`],
])}
</p>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static const TRAFFIC_LIGHTS = ["红灯", "黄灯", "绿灯"];
<p>现在亮着的是: ${light}</p>
<p>
你应该
<if=light === "red">停下</if>
<else-if=light === "orange">慢行</else-if>
<if=light === "红灯">停下</if>
<else-if=light === "黄灯">慢行</else-if>
<else>赶紧走</else>
</p>
6 changes: 3 additions & 3 deletions content/2-模板语法/6-条件渲染/react/TrafficLight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default function TrafficLight() {
<p>现在亮着的是: {light}</p>
<p>
你应该
{light === "red" && <span>停下</span>}
{light === "orange" && <span>慢行</span>}
{light === "green" && <span>赶紧走</span>}
{light === "红灯" && <span>停下</span>}
{light === "黄灯" && <span>慢行</span>}
{light === "绿灯" && <span>赶紧走</span>}
</p>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions content/2-模板语法/6-条件渲染/solid/TrafficLight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default function TrafficLight() {
<p>
你应该
<Switch>
<Match when={light() === "red"}>
<Match when={light() === "红灯"}>
<span>停下</span>
</Match>
<Match when={light() === "orange"}>
<Match when={light() === "黄灯"}>
<span>慢行</span>
</Match>
<Match when={light() === "green"}>
<Match when={light() === "绿灯"}>
<span>赶紧走</span>
</Match>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<p>现在亮着的是: {light}</p>
<p>
你应该
{#if light === "red"}
{#if light === "红灯"}
<span>停下</span>
{:else if light === "orange"}
{:else if light === "黄灯"}
<span>慢行</span>
{:else if light === "green"}
{:else if light === "绿灯"}
<span>赶紧走</span>
{/if}
</p>

0 comments on commit 22b124d

Please sign in to comment.