mirror of https://github.com/ElemeFE/element
Chore: replace var with let and const (#9774)
parent
c4ac575f3c
commit
ad07722aab
|
@ -131,7 +131,7 @@
|
|||
const disabledDate = this.disabledDate;
|
||||
const now = clearHours(new Date());
|
||||
|
||||
for (var i = 0; i < 6; i++) {
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const row = rows[i];
|
||||
|
||||
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];
|
||||
if (!cell) {
|
||||
cell = { row: i, column: j, type: 'normal', inRange: false, start: false, end: false };
|
||||
|
@ -455,7 +455,7 @@
|
|||
} else if (selectionMode === 'day') {
|
||||
this.$emit('pick', newDate);
|
||||
} else if (selectionMode === 'week') {
|
||||
var weekNumber = getWeekNumber(newDate);
|
||||
const weekNumber = getWeekNumber(newDate);
|
||||
|
||||
const value = newDate.getFullYear() + 'w' + weekNumber;
|
||||
this.$emit('pick', {
|
||||
|
|
|
@ -243,7 +243,7 @@
|
|||
render(h) {
|
||||
let { hide, splitButton, type, dropdownSize } = this;
|
||||
|
||||
var handleMainButtonClick = (event) => {
|
||||
const handleMainButtonClick = (event) => {
|
||||
this.$emit('click', event);
|
||||
hide();
|
||||
};
|
||||
|
|
|
@ -89,20 +89,20 @@
|
|||
return this.for || this.prop;
|
||||
},
|
||||
labelStyle() {
|
||||
var ret = {};
|
||||
const ret = {};
|
||||
if (this.form.labelPosition === 'top') return ret;
|
||||
var labelWidth = this.labelWidth || this.form.labelWidth;
|
||||
const labelWidth = this.labelWidth || this.form.labelWidth;
|
||||
if (labelWidth) {
|
||||
ret.width = labelWidth;
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
contentStyle() {
|
||||
var ret = {};
|
||||
const ret = {};
|
||||
const label = this.label;
|
||||
if (this.form.labelPosition === 'top' || this.form.inline) 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) {
|
||||
ret.marginLeft = labelWidth;
|
||||
}
|
||||
|
@ -123,10 +123,10 @@
|
|||
fieldValue: {
|
||||
cache: false,
|
||||
get() {
|
||||
var model = this.form.model;
|
||||
const model = this.form.model;
|
||||
if (!model || !this.prop) { return; }
|
||||
|
||||
var path = this.prop;
|
||||
let path = this.prop;
|
||||
if (path.indexOf(':') !== -1) {
|
||||
path = path.replace(/:/, '.');
|
||||
}
|
||||
|
@ -171,7 +171,7 @@
|
|||
methods: {
|
||||
validate(trigger, callback = noop) {
|
||||
this.validateDisabled = false;
|
||||
var rules = this.getFilteredRule(trigger);
|
||||
const rules = this.getFilteredRule(trigger);
|
||||
if ((!rules || rules.length === 0) && this.required === undefined) {
|
||||
callback();
|
||||
return true;
|
||||
|
@ -179,7 +179,7 @@
|
|||
|
||||
this.validateState = 'validating';
|
||||
|
||||
var descriptor = {};
|
||||
const descriptor = {};
|
||||
if (rules && rules.length > 0) {
|
||||
rules.forEach(rule => {
|
||||
delete rule.trigger;
|
||||
|
@ -187,8 +187,8 @@
|
|||
}
|
||||
descriptor[this.prop] = rules;
|
||||
|
||||
var validator = new AsyncValidator(descriptor);
|
||||
var model = {};
|
||||
const validator = new AsyncValidator(descriptor);
|
||||
const model = {};
|
||||
|
||||
model[this.prop] = this.fieldValue;
|
||||
|
||||
|
@ -226,16 +226,16 @@
|
|||
}
|
||||
},
|
||||
getRules() {
|
||||
var formRules = this.form.rules;
|
||||
var selfRules = this.rules;
|
||||
var requiredRule = this.required !== undefined ? { required: !!this.required } : [];
|
||||
let formRules = this.form.rules;
|
||||
const selfRules = this.rules;
|
||||
const requiredRule = this.required !== undefined ? { required: !!this.required } : [];
|
||||
|
||||
formRules = formRules ? getPropByPath(formRules, this.prop || '').o[this.prop || ''] : [];
|
||||
|
||||
return [].concat(selfRules || formRules || []).concat(requiredRule);
|
||||
},
|
||||
getFilteredRule(trigger) {
|
||||
var rules = this.getRules();
|
||||
const rules = this.getRules();
|
||||
|
||||
return rules.filter(rule => {
|
||||
return !rule.trigger || rule.trigger.indexOf(trigger) !== -1;
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
},
|
||||
resizeTextarea() {
|
||||
if (this.$isServer) return;
|
||||
var { autosize, type } = this;
|
||||
const { autosize, type } = this;
|
||||
if (type !== 'textarea') return;
|
||||
if (!autosize) {
|
||||
this.textareaCalcStyle = {
|
||||
|
|
|
@ -213,15 +213,15 @@
|
|||
|
||||
validate() {
|
||||
if (this.$type === 'prompt') {
|
||||
var inputPattern = this.inputPattern;
|
||||
const inputPattern = this.inputPattern;
|
||||
if (inputPattern && !inputPattern.test(this.inputValue || '')) {
|
||||
this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error');
|
||||
addClass(this.getInputElement(), 'invalid');
|
||||
return false;
|
||||
}
|
||||
var inputValidator = this.inputValidator;
|
||||
const inputValidator = this.inputValidator;
|
||||
if (typeof inputValidator === 'function') {
|
||||
var validateResult = inputValidator(this.inputValue);
|
||||
const validateResult = inputValidator(this.inputValue);
|
||||
if (validateResult === false) {
|
||||
this.editorErrorMessage = this.inputErrorMessage || t('el.messagebox.error');
|
||||
addClass(this.getInputElement(), 'invalid');
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
},
|
||||
computed: {
|
||||
barStyle() {
|
||||
var style = {};
|
||||
const style = {};
|
||||
style.width = this.percentage + '%';
|
||||
return style;
|
||||
},
|
||||
|
@ -82,16 +82,16 @@
|
|||
return (this.strokeWidth / this.width * 100).toFixed(1);
|
||||
},
|
||||
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}`;
|
||||
},
|
||||
perimeter() {
|
||||
var radius = 50 - parseFloat(this.relativeStrokeWidth) / 2;
|
||||
const radius = 50 - parseFloat(this.relativeStrokeWidth) / 2;
|
||||
return 2 * Math.PI * radius;
|
||||
},
|
||||
circlePathStyle() {
|
||||
var perimeter = this.perimeter;
|
||||
const perimeter = this.perimeter;
|
||||
return {
|
||||
strokeDasharray: `${perimeter}px,${perimeter}px`,
|
||||
strokeDashoffset: (1 - this.percentage / 100) * perimeter + 'px',
|
||||
|
@ -99,7 +99,7 @@
|
|||
};
|
||||
},
|
||||
stroke() {
|
||||
var ret;
|
||||
let ret;
|
||||
switch (this.status) {
|
||||
case 'success':
|
||||
ret = '#13ce66';
|
||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
|||
|
||||
computed: {
|
||||
style() {
|
||||
var ret = {};
|
||||
const ret = {};
|
||||
|
||||
if (this.gutter) {
|
||||
ret.marginLeft = `-${this.gutter / 2}px`;
|
||||
|
|
|
@ -105,9 +105,9 @@ export default {
|
|||
const self = this;
|
||||
!this.$isServer && window.addEventListener('message', (event) => {
|
||||
if (!self.file) return;
|
||||
var targetOrigin = new URL(self.action).origin;
|
||||
const targetOrigin = new URL(self.action).origin;
|
||||
if (event.origin !== targetOrigin) return;
|
||||
var response = event.data;
|
||||
const response = event.data;
|
||||
if (response.result === 'success') {
|
||||
self.onSuccess(response, self.file);
|
||||
} else if (response.result === 'failed') {
|
||||
|
|
Loading…
Reference in New Issue