Chore: replace var with let and const (#9774)

pull/9780/head
阿林 2018-02-11 16:37:58 +08:00 committed by 杨奕
parent c4ac575f3c
commit ad07722aab
8 changed files with 30 additions and 30 deletions

View File

@ -131,7 +131,7 @@
const disabledDate = this.disabledDate; const disabledDate = this.disabledDate;
const now = clearHours(new Date()); const now = clearHours(new Date());
for (var i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
const row = rows[i]; const row = rows[i];
if (this.showWeekNumber) { if (this.showWeekNumber) {
@ -140,7 +140,7 @@
} }
} }
for (var j = 0; j < 7; j++) { for (let j = 0; j < 7; j++) {
let cell = row[this.showWeekNumber ? j + 1 : j]; let cell = row[this.showWeekNumber ? j + 1 : j];
if (!cell) { if (!cell) {
cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false }; cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false };
@ -455,7 +455,7 @@
} else if (selectionMode === 'day') { } else if (selectionMode === 'day') {
this.$emit('pick', newDate); this.$emit('pick', newDate);
} else if (selectionMode === 'week') { } else if (selectionMode === 'week') {
var weekNumber = getWeekNumber(newDate); const weekNumber = getWeekNumber(newDate);
const value = newDate.getFullYear() + 'w' + weekNumber; const value = newDate.getFullYear() + 'w' + weekNumber;
this.$emit('pick', { this.$emit('pick', {

View File

@ -243,7 +243,7 @@
render(h) { render(h) {
let { hide, splitButton, type, dropdownSize } = this; let { hide, splitButton, type, dropdownSize } = this;
var handleMainButtonClick = (event) => { const handleMainButtonClick = (event) => {
this.$emit('click', event); this.$emit('click', event);
hide(); hide();
}; };

View File

@ -89,20 +89,20 @@
return this.for || this.prop; return this.for || this.prop;
}, },
labelStyle() { labelStyle() {
var ret = {}; const ret = {};
if (this.form.labelPosition === 'top') return ret; if (this.form.labelPosition === 'top') return ret;
var labelWidth = this.labelWidth || this.form.labelWidth; const labelWidth = this.labelWidth || this.form.labelWidth;
if (labelWidth) { if (labelWidth) {
ret.width = labelWidth; ret.width = labelWidth;
} }
return ret; return ret;
}, },
contentStyle() { contentStyle() {
var ret = {}; const ret = {};
const label = this.label; const label = this.label;
if (this.form.labelPosition === 'top' || this.form.inline) return ret; if (this.form.labelPosition === 'top' || this.form.inline) return ret;
if (!label && !this.labelWidth && this.isNested) return ret; if (!label && !this.labelWidth && this.isNested) return ret;
var labelWidth = this.labelWidth || this.form.labelWidth; const labelWidth = this.labelWidth || this.form.labelWidth;
if (labelWidth) { if (labelWidth) {
ret.marginLeft = labelWidth; ret.marginLeft = labelWidth;
} }
@ -123,10 +123,10 @@
fieldValue: { fieldValue: {
cache: false, cache: false,
get() { get() {
var model = this.form.model; const model = this.form.model;
if (!model || !this.prop) { return; } if (!model || !this.prop) { return; }
var path = this.prop; let path = this.prop;
if (path.indexOf(':') !== -1) { if (path.indexOf(':') !== -1) {
path = path.replace(/:/, '.'); path = path.replace(/:/, '.');
} }
@ -171,7 +171,7 @@
methods: { methods: {
validate(trigger, callback = noop) { validate(trigger, callback = noop) {
this.validateDisabled = false; this.validateDisabled = false;
var rules = this.getFilteredRule(trigger); const rules = this.getFilteredRule(trigger);
if ((!rules || rules.length === 0) && this.required === undefined) { if ((!rules || rules.length === 0) && this.required === undefined) {
callback(); callback();
return true; return true;
@ -179,7 +179,7 @@
this.validateState = 'validating'; this.validateState = 'validating';
var descriptor = {}; const descriptor = {};
if (rules && rules.length > 0) { if (rules && rules.length > 0) {
rules.forEach(rule => { rules.forEach(rule => {
delete rule.trigger; delete rule.trigger;
@ -187,8 +187,8 @@
} }
descriptor[this.prop] = rules; descriptor[this.prop] = rules;
var validator = new AsyncValidator(descriptor); const validator = new AsyncValidator(descriptor);
var model = {}; const model = {};
model[this.prop] = this.fieldValue; model[this.prop] = this.fieldValue;
@ -226,16 +226,16 @@
} }
}, },
getRules() { getRules() {
var formRules = this.form.rules; let formRules = this.form.rules;
var selfRules = this.rules; const selfRules = this.rules;
var requiredRule = this.required !== undefined ? { required: !!this.required } : []; const requiredRule = this.required !== undefined ? { required: !!this.required } : [];
formRules = formRules ? getPropByPath(formRules, this.prop || '').o[this.prop || ''] : []; formRules = formRules ? getPropByPath(formRules, this.prop || '').o[this.prop || ''] : [];
return [].concat(selfRules || formRules || []).concat(requiredRule); return [].concat(selfRules || formRules || []).concat(requiredRule);
}, },
getFilteredRule(trigger) { getFilteredRule(trigger) {
var rules = this.getRules(); const rules = this.getRules();
return rules.filter(rule => { return rules.filter(rule => {
return !rule.trigger || rule.trigger.indexOf(trigger) !== -1; return !rule.trigger || rule.trigger.indexOf(trigger) !== -1;

View File

@ -234,7 +234,7 @@
}, },
resizeTextarea() { resizeTextarea() {
if (this.$isServer) return; if (this.$isServer) return;
var { autosize, type } = this; const { autosize, type } = this;
if (type !== 'textarea') return; if (type !== 'textarea') return;
if (!autosize) { if (!autosize) {
this.textareaCalcStyle = { this.textareaCalcStyle = {

View File

@ -213,15 +213,15 @@
validate() { validate() {
if (this.$type === 'prompt') { if (this.$type === 'prompt') {
var inputPattern = this.inputPattern; const inputPattern = this.inputPattern;
if (inputPattern && !inputPattern.test(this.inputValue || '')) { if (inputPattern && !inputPattern.test(this.inputValue || '')) {
this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error'); this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error');
addClass(this.getInputElement(), 'invalid'); addClass(this.getInputElement(), 'invalid');
return false; return false;
} }
var inputValidator = this.inputValidator; const inputValidator = this.inputValidator;
if (typeof inputValidator === 'function') { if (typeof inputValidator === 'function') {
var validateResult = inputValidator(this.inputValue); const validateResult = inputValidator(this.inputValue);
if (validateResult === false) { if (validateResult === false) {
this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error'); this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error');
addClass(this.getInputElement(), 'invalid'); addClass(this.getInputElement(), 'invalid');

View File

@ -74,7 +74,7 @@
}, },
computed: { computed: {
barStyle() { barStyle() {
var style = {}; const style = {};
style.width = this.percentage + '%'; style.width = this.percentage + '%';
return style; return style;
}, },
@ -82,16 +82,16 @@
return (this.strokeWidth / this.width * 100).toFixed(1); return (this.strokeWidth / this.width * 100).toFixed(1);
}, },
trackPath() { trackPath() {
var radius = parseInt(50 - parseFloat(this.relativeStrokeWidth) / 2, 10); const radius = parseInt(50 - parseFloat(this.relativeStrokeWidth) / 2, 10);
return `M 50 50 m 0 -${radius} a ${radius} ${radius} 0 1 1 0 ${radius * 2} a ${radius} ${radius} 0 1 1 0 -${radius * 2}`; return `M 50 50 m 0 -${radius} a ${radius} ${radius} 0 1 1 0 ${radius * 2} a ${radius} ${radius} 0 1 1 0 -${radius * 2}`;
}, },
perimeter() { perimeter() {
var radius = 50 - parseFloat(this.relativeStrokeWidth) / 2; const radius = 50 - parseFloat(this.relativeStrokeWidth) / 2;
return 2 * Math.PI * radius; return 2 * Math.PI * radius;
}, },
circlePathStyle() { circlePathStyle() {
var perimeter = this.perimeter; const perimeter = this.perimeter;
return { return {
strokeDasharray: `${perimeter}px,${perimeter}px`, strokeDasharray: `${perimeter}px,${perimeter}px`,
strokeDashoffset: (1 - this.percentage / 100) * perimeter + 'px', strokeDashoffset: (1 - this.percentage / 100) * perimeter + 'px',
@ -99,7 +99,7 @@
}; };
}, },
stroke() { stroke() {
var ret; let ret;
switch (this.status) { switch (this.status) {
case 'success': case 'success':
ret = '#13ce66'; ret = '#13ce66';

View File

@ -22,7 +22,7 @@ export default {
computed: { computed: {
style() { style() {
var ret = {}; const ret = {};
if (this.gutter) { if (this.gutter) {
ret.marginLeft = `-${this.gutter / 2}px`; ret.marginLeft = `-${this.gutter / 2}px`;

View File

@ -105,9 +105,9 @@ export default {
const self = this; const self = this;
!this.$isServer && window.addEventListener('message', (event) => { !this.$isServer && window.addEventListener('message', (event) => {
if (!self.file) return; if (!self.file) return;
var targetOrigin = new URL(self.action).origin; const targetOrigin = new URL(self.action).origin;
if (event.origin !== targetOrigin) return; if (event.origin !== targetOrigin) return;
var response = event.data; const response = event.data;
if (response.result === 'success') { if (response.result === 'success') {
self.onSuccess(response, self.file); self.onSuccess(response, self.file);
} else if (response.result === 'failed') { } else if (response.result === 'failed') {