Skip to content

Commit e814224

Browse files
JinjiangJustineo
andauthored
Update from vuejs.org (vuejs#1075)
* updated from vuejs.org 34df294...3ed3359 * Apply suggestions from code review Co-Authored-By: GU Yiling <[email protected]> * Update forms.md * Update form-validation.md Co-authored-by: GU Yiling <[email protected]>
1 parent deaa935 commit e814224

File tree

155 files changed

+4297
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+4297
-434
lines changed

_config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ pagination_dir: page
7777
# Disqus
7878
disqus_shortname:
7979

80+
# Include/Exclude Files/Folders
81+
exclude:
82+
## Exclude example code from Nunjucks
83+
- "v2/examples/vue-20-*/*"
84+
8085
# Extensions
8186
## Plugins: https://github.com/hexojs/hexo/wiki/Plugins
8287
## Themes: https://github.com/hexojs/hexo/wiki/Themes

assets/why-vue/arabic.js.srt

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ H2 إلى قائمة غير مرتبة،
411411

412412
94
413413
00:03:57,460 --> 00:03:59,850
414-
دعنا نلغي ​​العنصر الأخير من المصفوفة
414+
دعنا نلغي العنصر الأخير من المصفوفة
415415

416416
95
417417
00:03:59,850 --> 00:04:01,828

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cn.vuejs.org",
33
"private": true,
44
"hexo": {
5-
"version": "3.7.1"
5+
"version": "3.8.0"
66
},
77
"scripts": {
88
"start": "hexo server",

src/resources/partners.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ partners_list:
4242
name: Modus Create
4343
logo: https://res.cloudinary.com/modus-labs/image/upload/v1533109874/modus/logo-vertical-black.svg
4444
description:
45-
"Modus Create is a digital product agency that supports clients with business and product strategy consulting, customer experience, cloud services, and Agile software delivery. Our official partnerships with Atlassian, AWS, InVision, Cloudflare, GitHub, Ionic Framework, and Vue.js reinforce our proven results with digital transformation with organizations from startups to the Fortune 100."
45+
"Modus Create is a disruptive consulting firm that helps companies transform for success in the digital future.
46+
47+
Clients work with Modus to effect transformational change through a unique collaborative engagement model that focuses on strategy, product design/build, user experience, company culture, and process change to accelerate their response to digital disruption.
48+
49+
Modus is uniquely expert at executing within the new reality of global talent sourcing and globally distributed teams. Modus culture is based on recruiting only top talent regardless of their location. Modus delivers time zone-aligned, highly productive, English-speaking teams, accessibility, and a totally collaborative environment regardless of individual location.
50+
"
4651
proficiencies:
4752
- name: Vue.js
4853
url: https://moduscreate.com/partners/vue/?utm_source=Vue&utm_medium=Partner-Page&utm_campaign=Vue_partnerpage
@@ -89,7 +94,7 @@ partners_list:
8994
name: Monterail
9095
logo: Monterail.png
9196
description:
92-
"Monterail is a full-service software development company with 100+ experts on board delivering meaningful software for start-ups, SMBs and enterprises. We build for the Web with Ruby on Rails, Python, JavaScript, and Agile. We guarantee this: a product so qualitative and aligned with your vision, you’ll swear it was built in-house."
97+
"Monterail is a full-service software development company with 110+ experts on board delivering meaningful software for start-ups, SMBs and enterprises. We are organizers of the first official Vue-related conference in the world and authors of the State of Vue.js report (2017&2019). Our experts delivered 30 Vue.js-based projects so far."
9398
proficiencies:
9499
- name: VueJs
95100
url: https://hi.monterail.co/2NqPUa6
@@ -100,15 +105,15 @@ partners_list:
100105
- name: Python
101106
url: https://hi.monterail.co/2MXHLeb
102107
- name: Services
103-
url: https://www.monterail.com/services
108+
url: https://www.monterail.com/services?utm_medium=referral&utm_source=partner-list&utm_campaign=vue.js
104109
- name: Projects
105-
url: https://www.monterail.com/projects
110+
url: https://www.monterail.com/projects?utm_medium=referral&utm_source=partner-list&utm_campaign=vue.js
106111
location: Wrocław, Poland
107112
languages:
108113
- English
109114
- Polish
110115
url_text: www.monterail.com
111-
url_link: www.monterail.com/?utm_campaign=Vue.js&utm_source=partner-list
116+
url_link: www.monterail.com/services/vue-development?utm_campaign=Vue.js&utm_source=partner-list
112117
hire_url: www.monterail.com/contact
113118
114119
social_links:

src/v2/api/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ type: api
684684
handler: 'someMethod',
685685
immediate: true
686686
},
687+
// 你可以传入回调数组,它们会被逐一调用
687688
e: [
688689
'handle1',
689690
function handle2 (val, oldVal) { /* ... */ },

src/v2/cookbook/debugging-in-vscode.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = {
6464
"webRoot": "${workspaceFolder}/src",
6565
"breakOnLoad": true,
6666
"sourceMapPathOverrides": {
67-
"webpack:///./src/*": "${webRoot}/*"
67+
"webpack:///src/*": "${webRoot}/*"
6868
}
6969
},
7070
{

src/v2/cookbook/form-validation.md

+23-19
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const app = new Vue({
203203
e.preventDefault();
204204
},
205205
validEmail: function (email) {
206-
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
206+
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
207207
return re.test(email);
208208
}
209209
}
@@ -330,21 +330,26 @@ const app = new Vue({
330330

331331
## 服务端校验
332332

333-
在我们最终的示例中,我们构建了一些用到 Ajax 的服务端校验的东西。这个表单将会问你为一个新产品起名字,并且将会确保这个名字是唯一的。我们快速写了一个 [OpenWhisk](http://openwhisk.apache.org/) 的 serverless action 来进行这个校验。虽然这不是非常重要,但其逻辑如下:
333+
在我们最终的示例中,我们构建了一些用到 Ajax 的服务端校验的东西。这个表单将会问你为一个新产品起名字,并且将会确保这个名字是唯一的。我们快速写了一个 [Netlify](https://netlify.com/) 的 serverless action 来进行这个校验。虽然这不是非常重要,但其逻辑如下:
334334

335335
``` js
336-
function main(args) {
337-
return new Promise((resolve, reject) => {
338-
// 不好的产品名:vista, empire, mbp
336+
exports.handler = async (event, context) => {
337+
339338
const badNames = ['vista', 'empire', 'mbp'];
340-
341-
if (badNames.includes(args.name)) {
342-
reject({error: 'Existing product'});
339+
const name = event.queryStringParameters.name;
340+
341+
if (badNames.includes(name)) {
342+
return {
343+
statusCode: 400,
344+
body: JSON.stringify({error: 'Invalid name passed.'})
345+
}
346+
}
347+
348+
return {
349+
statusCode: 204
343350
}
344-
345-
resolve({status: 'ok'});
346-
});
347351
}
352+
348353
```
349354

350355
基本上除了“vista”、“empire”和“mbp”的名字都是可以接受的。好,让我们来看看表单。
@@ -386,7 +391,7 @@ function main(args) {
386391
这里没有任何特殊的东西。接下来我们再看看 JavaScript。
387392

388393
``` js
389-
const apiUrl = 'https://openwhisk.ng.bluemix.net/api/v1/web/rcamden%40us.ibm.com_My%20Space/safeToDelete/productName.json?name=';
394+
const apiUrl = 'https://vuecookbook.netlify.com/.netlify/functions/product-name?name=';
390395

391396
const app = new Vue({
392397
el: '#app',
@@ -404,13 +409,12 @@ const app = new Vue({
404409
this.errors.push('Product name is required.');
405410
} else {
406411
fetch(apiUrl + encodeURIComponent(this.name))
407-
.then(res => res.json())
408-
.then(res => {
409-
if (res.error) {
410-
this.errors.push(res.error);
411-
} else {
412-
// 在成功的时候重定向到一个新的 URL 或做一些别的事情
413-
alert('ok!');
412+
.then(async res => {
413+
if (res.status === 204) {
414+
alert('OK');
415+
} else if (res.status === 400) {
416+
let errorResponse = await res.json();
417+
this.errors.push(errorResponse.error);
414418
}
415419
});
416420
}

src/v2/examples/commits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 1
66

77
> 这个例子从 Github 的 API 中获取了最新的 Vue.js 提交数据,并且以列表形式将它们展示了出来。你可以轻松地切换 master 和 dev 分支。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/c5g8xnar/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-github-commits?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/deepstream.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 9
66

77
> 这个例子使用 [deepstreamHub](https://deepstreamhub.com/) 在客户端之间实时同步数据、发送事件、远程程序调用 (你可以多开几个浏览器窗口试一试)。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/ff0sp9hw/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-realtime-with-deepstreamhub?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/elastic-header.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ type: examples
44
order: 7
55
---
66

7-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/y91wy85p/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
7+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-elastic-header?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/firebase.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ order: 10
55
---
66

77
> 本示例使用 [Firebase](https://firebase.google.com/) 作为数据存储后端,同时在客户端进行数据实时同步 (你可以在多个浏览器窗口去打开它来验证)。另外,它通过计算属性实时验证,并且添加/移除选项时触发 CSS 过渡。
8-
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/pyLbpzzx/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
8+
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-firebase-validation?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/grid-component.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 3
66

77
> 本示例创建了一个可复用组件,可结合外部数据来使用它。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/Tertia/vbyon64p/6/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-grid-component?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 0
66

77
> 蠢萌的 Markdown 编辑器。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/0dzvcf4d/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-markdown-editor?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/modal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 6
66

77
> 使用到的特性:组件,prop 传递,内容插入(content insertion),过渡 (transitions)。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/mwLbw11k/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-modal-component?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/select2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 8
66

77
> 在本例中,我们整合了第三方 jQuery 插件 (select2),怎么做到的呢?就是把它内嵌在一个常用组件中。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/d131Lebj/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-wrapper-component?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/svg.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 5
66

77
> 本示例展示了一个结合体,它由常用组件、计算属性、2 种绑定方式和 SVG 的支持组成。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/mhrckqgq/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-svg-graph?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/todomvc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ order: 11
66

77
> 本例是一个完全和规范一致的 TodoMVC 实现,只用了 120 行有效的 JavaScript (不包含注释和空行)。
88
9-
<p class="tip">Note that if your web browser is configured to block 3rd-party data/cookies, the example below will not work, as the `localStorage` data will fail to be saved from JSFiddle. You'll have to click on `Edit in JSFiddle` to see the live result.</p>
9+
<p class="tip">Note that if your web browser is configured to block 3rd-party data/cookies, the example below will not work, as the `localStorage` data will fail to be saved. You'll have to click on `Open Sandbox` to see the live result.</p>
1010

11-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/4dr2fLb7/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
11+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-todomvc?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/tree-view.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 4
66

77
> 本示例是一个简单的树形视图实现,它展现了组件的递归使用。
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/pnqzspoe/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-tree-view?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Two-way Currency Filter</title>
5+
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
6+
<script src="https://cdnjs.cloudflare.com/ajax/libs/accounting.js/0.4.1/accounting.min.js"></script>
7+
</head>
8+
<body>
9+
<div id="app">
10+
<currency-input label="Price" v-bind:value.sync="price"></currency-input>
11+
<currency-input
12+
label="Shipping"
13+
v-bind:value.sync="shipping"
14+
></currency-input>
15+
<currency-input
16+
label="Handling"
17+
v-bind:value.sync="handling"
18+
></currency-input>
19+
<currency-input
20+
label="Discount"
21+
v-bind:value.sync="discount"
22+
></currency-input>
23+
24+
<p>Total: ${{ total }}</p>
25+
</div>
26+
27+
<script>
28+
Vue.component("currency-input", {
29+
template:
30+
'\
31+
<div>\
32+
<label v-if="label">{{ label }}</label>\
33+
<input\
34+
v-model="value | currency"\
35+
v-on:focus="selectAll"\
36+
>\
37+
</div>\
38+
',
39+
props: {
40+
value: {
41+
type: Number,
42+
default: 0,
43+
twoWay: true
44+
},
45+
label: {
46+
type: String,
47+
default: ""
48+
}
49+
},
50+
filters: {
51+
currency: {
52+
read: function(value) {
53+
return "$" + value.toFixed(2);
54+
},
55+
write: function(value) {
56+
var number = +value.replace(/[^\d.]/g, "");
57+
return isNaN(number) ? 0 : number;
58+
}
59+
}
60+
},
61+
methods: {
62+
selectAll: function(event) {
63+
// Workaround for Safari bug
64+
// http://stackoverflow.com/questions/1269722/selecting-text-on-focus-using-jquery-not-working-in-safari-and-chrome
65+
setTimeout(function() {
66+
event.target.select();
67+
}, 0);
68+
}
69+
}
70+
});
71+
72+
new Vue({
73+
el: "#app",
74+
data: {
75+
price: 0,
76+
shipping: 0,
77+
handling: 0,
78+
discount: 0
79+
},
80+
computed: {
81+
total: function() {
82+
return this.price + this.shipping + this.handling - this.discount;
83+
}
84+
}
85+
});
86+
</script>
87+
</body>
88+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "vue-10-two-way-currency-filter-v2",
3+
"version": "1.0.0",
4+
"description": "Showing how delayed state updates can cause strange behavior.",
5+
"main": "index.html",
6+
"scripts": {
7+
"start": "serve"
8+
},
9+
"keywords": [],
10+
"license": "MIT",
11+
"devDependencies": {
12+
"serve": "^11.2.0"
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"template": "static"
3+
}

0 commit comments

Comments
 (0)