Skip to content

Commit

Permalink
docs: translate step 3 of tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodong2008 committed Apr 26, 2024
1 parent b954e08 commit ff1bc0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/tutorial/src/step-3/App/template.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>Make me red</h1> <!-- 此处添加一个动态 class 绑定 -->
<h1>Make me red</h1> <!-- 此處添加一個動態 class 綁定 -->
12 changes: 6 additions & 6 deletions src/tutorial/src/step-3/description.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Attribute 绑定 {#attribute-bindings}
# 屬性綁定 {#attribute-bindings}

在 Vue 中,mustache 语法 (即双大括号) 只能用于文本插值。为了给 attribute 绑定一个动态值,需要使用 `v-bind` 指令:
在 Vue 中,mustache 語法 (即雙大括號) 只能用於文本插值。為了給屬性綁定一個動態值,需要使用 `v-bind` 指令:

```vue-html
<div v-bind:id="dynamicId"></div>
```

**指令**是由 `v-` 开头的一种特殊 attribute。它们是 Vue 模板语法的一部分。和文本插值类似,指令的值是可以访问组件状态的 JavaScript 表达式。关于 `v-bind` 和指令语法的完整细节请详阅<a target="_blank" href="/guide/essentials/template-syntax.html">指南 - 模板语法</a>。
**指令**是由 `v-` 開頭的一種特殊屬性。它們是 Vue 模板語法的一部分。和文本插值類似,指令的值是可以訪問組件狀態的 JavaScript 表達式。關於 `v-bind` 和指令語法的完整細節請詳閱<a target="_blank" href="/guide/essentials/template-syntax.html">指南 - 模板語法</a>。

冒号后面的部分 (`:id`) 是指令的“参数”。此处,元素的 `id` attribute 将与组件状态里的 `dynamicId` 属性保持同步
冒號後面的部分 (`:id`) 是指令的“參數”。此處,元素的 `id` attribute 將與組件狀態裡的 `dynamicId` 屬性保持同步

由于 `v-bind` 使用地非常频繁,它有一个专门的简写语法
由於 `v-bind` 使用地非常頻繁,它有一個專門的簡寫語法

```vue-html
<div :id="dynamicId"></div>
```

现在,试着把一个动态的 `class` 绑定添加到这个 `<h1>` 上,并使用 `titleClass` 的<span class="options-api">数据属性</span><span class="composition-api"> ref </span>作为它的值。如果绑定正确,文字将会变为红色
現在,試著把一個動態的 `class` 綁定添加到這個 `<h1>` 上,並使用 `titleClass` 的<span class="options-api">數據屬性</span><span class="composition-api"> ref </span>作為它的值。如果綁定正確,文字將會變為紅色

0 comments on commit ff1bc0b

Please sign in to comment.