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
{{ message }}
This repository was archived by the owner on Sep 16, 2020. It is now read-only.
* 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, fixesvuejs#1195
* fix SG typos, fixesvuejs#1194
* make it more obvious in SG that details can be expanded, fixesvuejs#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
Copy file name to clipboardExpand all lines: src/v2/guide/instance.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ new Vue({
120
120
121
121
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.
122
122
123
-
<pclass="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
+
<pclass="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>
Copy file name to clipboardExpand all lines: src/v2/guide/single-file-components.md
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,10 @@ Even if you don't like the idea of Single-File Components, you can still leverag
50
50
51
51
## Getting Started
52
52
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
+
53
57
### For Users New to Module Build Systems in JavaScript
54
58
55
59
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
58
62
59
63
-**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.
60
64
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!
64
66
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.
Copy file name to clipboardExpand all lines: src/v2/style-guide/index.md
+54-13Lines changed: 54 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Where multiple, equally good options exist, an arbitrary choice can be made to e
30
30
31
31
1. train your brain to more easily parse most of the community code you encounter
32
32
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
34
34
35
35
### Priority D: Use with Caution
36
36
@@ -352,7 +352,7 @@ Beyond the `scoped` attribute, using unique class names can help ensure that 3rd
352
352
<buttonclass="button button-close">X</button>
353
353
</template>
354
354
355
-
<!-- Using the scoped attribute -->
355
+
<!-- Using the `scoped` attribute -->
356
356
<stylescoped>
357
357
.button {
358
358
border: none;
@@ -684,6 +684,42 @@ components/
684
684
685
685
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.
686
686
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
+
687
723
{% raw %}<divclass="style-example example-bad">{% endraw %}
688
724
#### Bad
689
725
@@ -847,7 +883,7 @@ Unfortunately, HTML doesn't allow custom elements to be self-closing - only [off
847
883
848
884
### Component name casing in templates <supdata-p="b">strongly recommended</sup>
849
885
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.**
851
887
852
888
PascalCase has a few advantages over kebab-case:
853
889
@@ -857,6 +893,8 @@ PascalCase has a few advantages over kebab-case:
857
893
858
894
Unfortunately, due to HTML's case insensitivity, DOM templates must still use kebab-case.
859
895
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
+
860
898
{% raw %}<divclass="style-example example-bad">{% endraw %}
861
899
#### Bad
862
900
@@ -865,11 +903,6 @@ Unfortunately, due to HTML's case insensitivity, DOM templates must still use ke
865
903
<mycomponent/>
866
904
```
867
905
868
-
```html
869
-
<!-- In single-file components and string templates -->
870
-
<my-component/>
871
-
```
872
-
873
906
```html
874
907
<!-- In single-file components and string templates -->
875
908
<myComponent/>
@@ -893,6 +926,13 @@ Unfortunately, due to HTML's case insensitivity, DOM templates must still use ke
893
926
<!-- In DOM templates -->
894
927
<my-component></my-component>
895
928
```
929
+
930
+
OR
931
+
932
+
```html
933
+
<!-- Everywhere -->
934
+
<my-component></my-component>
935
+
```
896
936
{% raw %}</div>{% endraw %}
897
937
898
938
@@ -913,7 +953,8 @@ In JavaScript, PascalCase is the convention for classes and prototype constructo
913
953
However, for applications that use **only** global component definitions via `Vue.component`, we recommend kebab-case instead. The reasons are:
914
954
915
955
- 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
+
917
958
{% raw %}</details>{% endraw %}
918
959
919
960
{% raw %}<divclass="style-example example-bad">{% endraw %}
@@ -1076,7 +1117,7 @@ In JavaScript, splitting objects with multiple properties over multiple lines is
1076
1117
1077
1118
1078
1119
1079
-
### Complex expressions in templates <supdata-p="b">strongly recommended</sup>
1120
+
### Simple expressions in templates <supdata-p="b">strongly recommended</sup>
1080
1121
1081
1122
**Component templates should only include simple expressions, with more complex expressions refactored into computed properties or methods.**
0 commit comments