Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Commit 55d07a1

Browse files
authored
Sync with upstream (#26)
* Replace `true` with truthy (vuejs#1196) * Change "Registration" to "Global Registration" (vuejs#1192) * typos (vuejs#1191) * [Website]: Let menu to be above add (vuejs#1188) Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com> * Fix: Demystified markdown logic (vuejs#1186) * Fix: Demystified markdown logic I have changes jsfiddle link with a similar jsfiddle. The difference between two jsfiddle is in javascript code, `marked()` has a comment mentioning its source as external library. This is important because it is easy to assume that `marked()` cmes from an external library instead of Vue, especially for a beginner. * make dependencies apparent in markdown example * Correct the heading tags (vuejs#1181) correct the opening and closing `h4` tags * Make the statement less definitive (vuejs#1190) * Make the statement less definitive * Reword the tip * add SG exception where kebab-case everywhere is also acceptable for components in templates * revise single-file components, with new example sandbox * Add Additional Resources to ecosystem dropdown (vuejs#1182) * Add additional resources to dropdown * reorganize ecosystem dropdown, adding Tooling * Move roadmap to News section of ecosystem dropdown * Update "Core Plugins" to "Core Libraries" * rename SG complex expressions rule to simple * rename SG complex computed expressions rule to simple * address SG question about coupled component names, fixes vuejs#1195 * fix SG typos, fixes vuejs#1194 * make it more obvious in SG that details can be expanded, fixes vuejs#1170 * Update custom-directive.md (vuejs#1198) I suggest add this params demo because i can not understand when i saw this part,i think other people will have the same confusion * clarified titles of SG priority D rules * Re-translate the arrow function tip
1 parent 6205b7f commit 55d07a1

File tree

9 files changed

+87
-31
lines changed

9 files changed

+87
-31
lines changed

src/v2/examples/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 0
66

77
> Dead simple Markdown editor.
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/rdjjpc7a/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/0dzvcf4d/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

src/v2/guide/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Components are one of the most powerful features of Vue. They help you extend ba
1010

1111
## Using Components
1212

13-
### Registration
13+
### Global Registration
1414

1515
We've learned in the previous sections that we can create a new Vue instance with:
1616

src/v2/guide/custom-directive.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ If you want to register a directive locally instead, components also accept a `d
4343
directives: {
4444
focus: {
4545
// directive definition
46+
inserted: function (el) {
47+
el.focus()
48+
}
4649
}
4750
}
4851
```

src/v2/guide/instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ new Vue({
120120

121121
Các hook khác như [`mounted`](../api/#mounted), [`updated`](../api/#updated), và [`destroyed`](../api/#destroyed) cũng được gọi vào các giai đoạn khác nhau trong vòng đời của đối tượng. Tất cả các hook này đều được thực thi với ngữ cảnh `this` trỏ đến đối tượng Vue hiện hành.
122122

123-
<p class="tip">Đừng dùng [hàm mũi tên (arrow functions)](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) cho các thuộc tính tùy chọn hoặc callback như là `created: () => console.log(this.a)` hoặc `vm.$watch('a', newValue => this.myMethod())`. Vì hàm mũi tên được bind vào ngữ cảnh cha (parent context), `this` sẽ không trỏ đến đối tượng Vue hiện hành và do đó `this.a` hoặc `this.myMethod` sẽ không trả về giá trị mà bạn mong đợi.</p>
123+
<p class="tip">Đừng dùng [hàm mũi tên (arrow functions)](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) cho các thuộc tính tùy chọn hoặc callback như là `created: () => console.log(this.a)` hoặc `vm.$watch('a', newValue => this.myMethod())`. Vì hàm mũi tên được bind vào ngữ cảnh cha (parent context), `this` sẽ không trỏ đến đối tượng Vue hiện hành. Do vậy `this.a` hoặc `this.myMethod` sẽ không trả về giá trị mà bạn mong đợi, mà thay vào đó thường là các lỗi `Uncaught TypeError: Cannot read property of undefined` hoặc `Uncaught TypeError: this.myMethod is not a function`.</p>
124124

125125
## Sơ đồ vòng đời
126126

src/v2/guide/single-file-components.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Even if you don't like the idea of Single-File Components, you can still leverag
5050

5151
## Getting Started
5252

53+
### Example Sandbox
54+
55+
If you want to dive right in and start playing with single-file components, check out [this simple todo app](https://codesandbox.io/s/o29j95wx9) on CodeSandbox.
56+
5357
### For Users New to Module Build Systems in JavaScript
5458

5559
With `.vue` components, we're entering the realm of advanced JavaScript applications. That means learning to use a few additional tools if you haven't already:
@@ -58,11 +62,9 @@ With `.vue` components, we're entering the realm of advanced JavaScript applicat
5862

5963
- **Modern JavaScript with ES2015/16**: Read through Babel's [Learn ES2015 guide](https://babeljs.io/docs/learn-es2015/). You don't have to memorize every feature right now, but keep this page as a reference you can come back to.
6064

61-
After you've taken a day to dive into these resources, we recommend checking out the [webpack-simple](https://github.com/vuejs-templates/webpack-simple) template. Follow the instructions and you should have a Vue project with `.vue` components, ES2015 and hot-reloading running in no time!
62-
63-
The template uses [Webpack](https://webpack.js.org/), a module bundler that takes a number of "modules" and then bundles them into your final application. To learn more about Webpack itself, check out [their official docs](https://webpack.js.org/configuration/) and [Webpack Academy](https://webpack.academy/p/the-core-concepts).
65+
After you've taken a day to dive into these resources, we recommend checking out the [webpack](https://vuejs-templates.github.io/webpack) template. Follow the instructions and you should have a Vue project with `.vue` components, ES2015, and hot-reloading in no time!
6466

65-
In Webpack, each module can be transformed by a "loader" before being included in the bundle, and Vue offers the [vue-loader](https://github.com/vuejs/vue-loader) plugin to take care of translating `.vue` single-file components. The [webpack-simple](https://github.com/vuejs-templates/webpack-simple) template has already set up everything for you, but if you'd like to learn more about how `.vue` components work with Webpack, you can read [the docs for vue-loader](https://vue-loader.vuejs.org).
67+
To learn more about Webpack itself, check out [their official docs](https://webpack.js.org/configuration/) and [Webpack Academy](https://webpack.academy/p/the-core-concepts). In Webpack, each file can be transformed by a "loader" before being included in the bundle, and Vue offers the [vue-loader](https://vue-loader.vuejs.org) plugin to translate single-file (`.vue`) components.
6668

6769
### For Advanced Users
6870

src/v2/style-guide/index.md

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Where multiple, equally good options exist, an arbitrary choice can be made to e
3030

3131
1. train your brain to more easily parse most of the community code you encounter
3232
2. be able to copy and paste most community code examples without modification
33-
2. often find new hires are already accustomed to your preferred coding style, at least in regards to Vue
33+
3. often find new hires are already accustomed to your preferred coding style, at least in regards to Vue
3434

3535
### Priority D: Use with Caution
3636

@@ -352,7 +352,7 @@ Beyond the `scoped` attribute, using unique class names can help ensure that 3rd
352352
<button class="button button-close">X</button>
353353
</template>
354354

355-
<!-- Using the scoped attribute -->
355+
<!-- Using the `scoped` attribute -->
356356
<style scoped>
357357
.button {
358358
border: none;
@@ -684,6 +684,42 @@ components/
684684

685685
If a component only makes sense in the context of a single parent component, that relationship should be evident in its name. Since editors typically organize files alphabetically, this also keeps these related files next to each other.
686686

687+
{% raw %}
688+
<details>
689+
<summary>
690+
<h4>Detailed Explanation</h4>
691+
</summary>
692+
{% endraw %}
693+
694+
You might be tempted to solve this problem by nesting child components in directories named after their parent. For example:
695+
696+
```
697+
components/
698+
|- TodoList/
699+
|- Item/
700+
|- index.vue
701+
|- Button.vue
702+
|- index.vue
703+
```
704+
705+
or:
706+
707+
```
708+
components/
709+
|- TodoList/
710+
|- Item/
711+
|- Button.vue
712+
|- Item.vue
713+
|- TodoList.vue
714+
```
715+
716+
This isn't recommended, as it results in:
717+
718+
- Many files with similar names, making rapid file switching in code editors more difficult.
719+
- Many nested sub-directories, which increases the time it takes to browse components in an editor's sidebar.
720+
721+
{% raw %}</details>{% endraw %}
722+
687723
{% raw %}<div class="style-example example-bad">{% endraw %}
688724
#### Bad
689725

@@ -847,7 +883,7 @@ Unfortunately, HTML doesn't allow custom elements to be self-closing - only [off
847883

848884
### Component name casing in templates <sup data-p="b">strongly recommended</sup>
849885

850-
**Component names should always be PascalCase in [single-file components](../guide/single-file-components.html) and string templates - but kebab-case in DOM templates.**
886+
**In most projects, component names should always be PascalCase in [single-file components](../guide/single-file-components.html) and string templates - but kebab-case in DOM templates.**
851887

852888
PascalCase has a few advantages over kebab-case:
853889

@@ -857,6 +893,8 @@ PascalCase has a few advantages over kebab-case:
857893

858894
Unfortunately, due to HTML's case insensitivity, DOM templates must still use kebab-case.
859895

896+
Also note that if you've already invested heavily in kebab-case, consistency with HTML conventions and being able to use the same casing across all your projects may be more important than the advantages listed above. In those cases, **using kebab-case everywhere is also acceptable.**
897+
860898
{% raw %}<div class="style-example example-bad">{% endraw %}
861899
#### Bad
862900

@@ -865,11 +903,6 @@ Unfortunately, due to HTML's case insensitivity, DOM templates must still use ke
865903
<mycomponent/>
866904
```
867905

868-
``` html
869-
<!-- In single-file components and string templates -->
870-
<my-component/>
871-
```
872-
873906
``` html
874907
<!-- In single-file components and string templates -->
875908
<myComponent/>
@@ -893,6 +926,13 @@ Unfortunately, due to HTML's case insensitivity, DOM templates must still use ke
893926
<!-- In DOM templates -->
894927
<my-component></my-component>
895928
```
929+
930+
OR
931+
932+
``` html
933+
<!-- Everywhere -->
934+
<my-component></my-component>
935+
```
896936
{% raw %}</div>{% endraw %}
897937

898938

@@ -913,7 +953,8 @@ In JavaScript, PascalCase is the convention for classes and prototype constructo
913953
However, for applications that use **only** global component definitions via `Vue.component`, we recommend kebab-case instead. The reasons are:
914954

915955
- It's rare that global components are ever referenced in JavaScript, so following a convention for JavaScript makes less sense.
916-
- These applications always include many in-DOM components, where kebab-case [**must** be used](#Component-name-casing-in-templates).
956+
- These applications always include many in-DOM templates, where [kebab-case **must** be used](#Component-name-casing-in-templates-strongly-recommended).
957+
917958
{% raw %}</details>{% endraw %}
918959

919960
{% raw %}<div class="style-example example-bad">{% endraw %}
@@ -1076,7 +1117,7 @@ In JavaScript, splitting objects with multiple properties over multiple lines is
10761117

10771118

10781119

1079-
### Complex expressions in templates <sup data-p="b">strongly recommended</sup>
1120+
### Simple expressions in templates <sup data-p="b">strongly recommended</sup>
10801121

10811122
**Component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods.**
10821123

@@ -1116,7 +1157,7 @@ computed: {
11161157

11171158

11181159

1119-
### Complex computed properties <sup data-p="b">strongly recommended</sup>
1160+
### Simple computed properties <sup data-p="b">strongly recommended</sup>
11201161

11211162
**Complex computed properties should be split into as many simpler properties as possible.**
11221163

@@ -1589,7 +1630,7 @@ button {
15891630

15901631

15911632

1592-
### Parent-child communication <sup data-p="d">use with caution</sup>
1633+
### Implicit parent-child communication <sup data-p="d">use with caution</sup>
15931634

15941635
**Props and events should be preferred for parent-child component communication, instead of `this.$parent` or mutating props.**
15951636

@@ -1682,7 +1723,7 @@ Vue.component('TodoItem', {
16821723

16831724

16841725

1685-
### Global state management <sup data-p="d">use with caution</sup>
1726+
### Non-flux state management <sup data-p="d">use with caution</sup>
16861727

16871728
**[Vuex](https://github.com/vuejs/vuex) should be preferred for global state management, instead of `this.$root` or a global event bus.**
16881729

themes/vue/layout/partials/ecosystem_dropdown.ejs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
<li class="nav-dropdown-container ecosystem">
22
<a class="nav-link">Hệ sinh thái</a><span class="arrow"></span>
33
<ul class="nav-dropdown">
4-
<li><a href="https://github.com/vuejs/roadmap" class="nav-link" target="_blank">Lộ trình phát triển</a></li>
54
<li><h4>Hỗ trợ</h4></li>
65
<li><ul>
76
<li><a href="https://forum.vuejs.org/" class="nav-link" target="_blank">Diễn đàn</a></li>
87
<li><a href="https://chat.vuejs.org/" class="nav-link" target="_blank">Chat</a></li>
9-
<li><a href="https://github.com/vuejs-templates" class="nav-link" target="_blank">Templates</a></li>
8+
</ul></li>
9+
<li><h4>Công cụ</h4></li>
10+
<li>
11+
<ul>
12+
<li><a href="https://github.com/vuejs/vue-devtools" class="nav-link" target="_blank">Vue Devtools</a></li>
13+
<li><a href="https://vuejs-templates.github.io/webpack" class="nav-link" target="_blank">Webpack Template</a></li>
14+
<li><a href="https://vue-loader.vuejs.org" class="nav-link" target="_blank">Vue Loader</a></li>
15+
</ul>
16+
</li>
17+
<li><h4>Thư viện chính thức</h4></li>
18+
<li><ul>
19+
<li><a href="https://router.vuejs.org/" class="nav-link" target="_blank">Vue Router</a></li>
20+
<li><a href="https://vuex.vuejs.org/" class="nav-link" target="_blank">Vuex</a></li>
21+
<li><a href="https://ssr.vuejs.org/" class="nav-link" target="_blank">Vue Server Renderer</a></li>
1022
</ul></li>
1123
<li><h4>Tin tức</h4></li>
1224
<li><ul>
25+
<li><a href="https://github.com/vuejs/roadmap" class="nav-link" target="_blank">Lộ trình phát triển</a></li>
1326
<li><a href="https://twitter.com/vuejs" class="nav-link" target="_blank">Twitter</a></li>
1427
<li><a href="https://medium.com/the-vue-point" class="nav-link" target="_blank">Blog</a></li>
1528
<li><a href="https://vuejobs.com/?ref=vuejs" class="nav-link" target="_blank">Việc làm</a></li>
1629
</ul></li>
17-
<li><h4>Plugin chính thức</h4></li>
18-
<li><ul>
19-
<li><a href="https://router.vuejs.org/" class="nav-link" target="_blank">Vue Router</a></li>
20-
<li><a href="https://vuex.vuejs.org/" class="nav-link" target="_blank">Vuex</a></li>
21-
<li><a href="https://ssr.vuejs.org/" class="nav-link" target="_blank">Vue Server Renderer</a></li>
22-
</ul></li>
2330
<li><h4>Tài nguyên</h4></li>
2431
<li><ul>
2532
<li><a href="https://github.com/vuejs" class="nav-link" target="_blank">Nhóm Vue.js trên GitHub</a></li>
@@ -28,5 +35,3 @@
2835
</ul></li>
2936
</ul>
3037
</li>
31-
32-

themes/vue/source/css/_style-guide.styl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ $style-guide-priority-d-color = white
3636
background-color #eee
3737
details
3838
position relative
39+
&:not([open]) summary
40+
&::after
41+
content "..."
42+
&:hover
43+
background rgba(255, 255, 255, .3)
3944
summary
4045
cursor pointer
4146
padding 1.6em

themes/vue/source/css/page.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
.content.with-sidebar
186186
margin-left: 290px
187187
#ad
188-
z-index: 7
188+
z-index: 1
189189
position: relative
190190
padding: 0
191191
bottom: 0

0 commit comments

Comments
 (0)