You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/style-guide/index.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1077,11 +1077,11 @@ props: {
1077
1077
1078
1078
1079
1079
1080
-
### Complex expressions in templates <supdata-p="b">强烈推荐</sup>
1080
+
### 避免模板中的复杂表达式 <supdata-p="b">强烈推荐</sup>
1081
1081
1082
-
**Component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods.**
1082
+
**组件模板应该只包含简单的表达式,复杂的表达式则应该重构为计算属性或方法。**
1083
1083
1084
-
Complex expressions in your templates make them less declarative. We should strive to describe _what_ should appear, not _how_ we're computing that value. Computed properties and methods also allow the code to be reused.
**Complex computed properties should be split into as many simpler properties as possible.**
1122
+
**应该把复杂计算属性分割为尽可能多的更简单的属性。**
1123
1123
1124
1124
{% raw %}
1125
1125
<details>
@@ -1128,21 +1128,21 @@ computed: {
1128
1128
</summary>
1129
1129
{% endraw %}
1130
1130
1131
-
Simpler, well-named computed properties are:
1131
+
更简单、命名得当的计算属性是这样的:
1132
1132
1133
-
-__Easier to test__
1133
+
-__易于测试__
1134
1134
1135
-
When each computed property contains only a very simple expression, with very few dependencies, it's much easier to write tests confirming that it works correctly.
1135
+
当每个计算属性都包含一个非常简单且很少依赖的表达式时,撰写测试以确保其正确工作就会更加容易。
1136
1136
1137
-
-__Easier to read__
1137
+
-__易于阅读__
1138
1138
1139
-
Simplifying computed properties forces you to give each value a descriptive name, even if it's not reused. This makes it much easier for other developers (and future you) to focus in on the code they care about and figure out what's going on.
Any value that can be named might be useful to the view. For example, we might decide to display a message telling the user how much money they saved. We might also decide to calculate sales tax, but perhaps display it separately, rather than as part of the final price.
**Non-empty HTML attribute values should always be inside quotes (single or double, whichever is not used in JS).**
1187
+
**非空 HTML 特性值应该始终带引号 (单引号或双引号,选你 JS 里不用的那个)。**
1188
1188
1189
-
While attribute values without any spaces are not required to have quotes in HTML, this practice often leads to _avoiding_ spaces, making attribute values less readable.
1189
+
在 HTML 中不带空格的特性值是可以没有引号的,但这样做常常导致_回避_带空格的特征值,让其可读性变差。
1190
1190
1191
1191
{% raw %}<divclass="style-example example-bad">{% endraw %}
1192
1192
#### 反例
@@ -1214,9 +1214,9 @@ While attribute values without any spaces are not required to have quotes in HTM
0 commit comments