mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-10-19 22:52:08 +08:00
chore: using includes instead of indexOf (#8261)
This commit is contained in:
parent
831091182a
commit
9fd71923f9
@ -124,7 +124,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hide border when color is linear-gradient
|
// hide border when color is linear-gradient
|
||||||
if (color.indexOf('gradient') !== -1) {
|
if (color.includes('gradient')) {
|
||||||
style.border = 0;
|
style.border = 0;
|
||||||
} else {
|
} else {
|
||||||
style.borderColor = color;
|
style.borderColor = color;
|
||||||
|
@ -252,7 +252,7 @@ export default createComponent({
|
|||||||
const values = state.tabs.map(
|
const values = state.tabs.map(
|
||||||
(tab) => tab.selectedOption?.[valueKey]
|
(tab) => tab.selectedOption?.[valueKey]
|
||||||
);
|
);
|
||||||
if (values.indexOf(value) !== -1) {
|
if (values.includes(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export default createComponent({
|
|||||||
if (checked) {
|
if (checked) {
|
||||||
const overlimit = max && value.length >= max;
|
const overlimit = max && value.length >= max;
|
||||||
|
|
||||||
if (!overlimit && value.indexOf(name) === -1) {
|
if (!overlimit && !value.includes(name)) {
|
||||||
value.push(name);
|
value.push(name);
|
||||||
|
|
||||||
if (props.bindGroup) {
|
if (props.bindGroup) {
|
||||||
|
@ -73,7 +73,7 @@ export default createComponent({
|
|||||||
|
|
||||||
return accordion
|
return accordion
|
||||||
? modelValue === name
|
? modelValue === name
|
||||||
: (modelValue as Array<number | string>).indexOf(name) !== -1;
|
: (modelValue as Array<number | string>).includes(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
linkChildren({ toggle, isExpanded });
|
linkChildren({ toggle, isExpanded });
|
||||||
|
@ -5,36 +5,36 @@ export function parseFormat(format: string, currentTime: CurrentTime): string {
|
|||||||
const { days } = currentTime;
|
const { days } = currentTime;
|
||||||
let { hours, minutes, seconds, milliseconds } = currentTime;
|
let { hours, minutes, seconds, milliseconds } = currentTime;
|
||||||
|
|
||||||
if (format.indexOf('DD') === -1) {
|
if (format.includes('DD')) {
|
||||||
hours += days * 24;
|
|
||||||
} else {
|
|
||||||
format = format.replace('DD', padZero(days));
|
format = format.replace('DD', padZero(days));
|
||||||
|
} else {
|
||||||
|
hours += days * 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.indexOf('HH') === -1) {
|
if (format.includes('HH')) {
|
||||||
minutes += hours * 60;
|
|
||||||
} else {
|
|
||||||
format = format.replace('HH', padZero(hours));
|
format = format.replace('HH', padZero(hours));
|
||||||
|
} else {
|
||||||
|
minutes += hours * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.indexOf('mm') === -1) {
|
if (format.includes('mm')) {
|
||||||
seconds += minutes * 60;
|
|
||||||
} else {
|
|
||||||
format = format.replace('mm', padZero(minutes));
|
format = format.replace('mm', padZero(minutes));
|
||||||
}
|
|
||||||
|
|
||||||
if (format.indexOf('ss') === -1) {
|
|
||||||
milliseconds += seconds * 1000;
|
|
||||||
} else {
|
} else {
|
||||||
format = format.replace('ss', padZero(seconds));
|
seconds += minutes * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.indexOf('S') !== -1) {
|
if (format.includes('ss')) {
|
||||||
|
format = format.replace('ss', padZero(seconds));
|
||||||
|
} else {
|
||||||
|
milliseconds += seconds * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.includes('S')) {
|
||||||
const ms = padZero(milliseconds, 3);
|
const ms = padZero(milliseconds, 3);
|
||||||
|
|
||||||
if (format.indexOf('SSS') !== -1) {
|
if (format.includes('SSS')) {
|
||||||
format = format.replace('SSS', ms);
|
format = format.replace('SSS', ms);
|
||||||
} else if (format.indexOf('SS') !== -1) {
|
} else if (format.includes('SS')) {
|
||||||
format = format.replace('SS', ms.slice(0, 2));
|
format = format.replace('SS', ms.slice(0, 2));
|
||||||
} else {
|
} else {
|
||||||
format = format.replace('S', ms.charAt(0));
|
format = format.replace('S', ms.charAt(0));
|
||||||
|
@ -27,7 +27,7 @@ export default createComponent({
|
|||||||
return Network;
|
return Network;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRESET_IMAGES.indexOf(image) !== -1) {
|
if (PRESET_IMAGES.includes(image)) {
|
||||||
image = `https://img01.yzcdn.cn/vant/empty-image-${image}.png`;
|
image = `https://img01.yzcdn.cn/vant/empty-image-${image}.png`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export default createComponent({
|
|||||||
|
|
||||||
const getFieldsByNames = (names?: string[]) => {
|
const getFieldsByNames = (names?: string[]) => {
|
||||||
if (names) {
|
if (names) {
|
||||||
return children.filter((field) => names.indexOf(field.name) !== -1);
|
return children.filter((field) => names.includes(field.name));
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ import Badge from '../badge';
|
|||||||
const [createComponent, bem] = createNamespace('icon');
|
const [createComponent, bem] = createNamespace('icon');
|
||||||
|
|
||||||
function isImage(name?: string) {
|
function isImage(name?: string) {
|
||||||
return name ? name.indexOf('/') !== -1 : false;
|
return name ? name.includes('/') : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
|
@ -121,7 +121,7 @@ export default createComponent({
|
|||||||
|
|
||||||
const nodes = [];
|
const nodes = [];
|
||||||
|
|
||||||
if (TEXT_STATUS.indexOf(status) !== -1) {
|
if (TEXT_STATUS.includes(status)) {
|
||||||
nodes.push(<div class={bem('text')}>{getStatusText()}</div>);
|
nodes.push(<div class={bem('text')}>{getStatusText()}</div>);
|
||||||
}
|
}
|
||||||
if (status === 'loading') {
|
if (status === 'loading') {
|
||||||
|
@ -34,7 +34,7 @@ const popupKeys = [
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
function getIconURL(icon: string) {
|
function getIconURL(icon: string) {
|
||||||
if (PRESET_ICONS.indexOf(icon) !== -1) {
|
if (PRESET_ICONS.includes(icon)) {
|
||||||
return `https://img01.yzcdn.cn/vant/share-sheet-${icon}.png`;
|
return `https://img01.yzcdn.cn/vant/share-sheet-${icon}.png`;
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
|
@ -190,7 +190,7 @@ export default createComponent({
|
|||||||
let formatted = formatNumber(String(value), !props.integer);
|
let formatted = formatNumber(String(value), !props.integer);
|
||||||
|
|
||||||
// limit max decimal length
|
// limit max decimal length
|
||||||
if (isDef(decimalLength) && formatted.indexOf('.') !== -1) {
|
if (isDef(decimalLength) && formatted.includes('.')) {
|
||||||
const pair = formatted.split('.');
|
const pair = formatted.split('.');
|
||||||
formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
|
formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ export default createComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const isActiveItem = (id: number | string) => {
|
const isActiveItem = (id: number | string) => {
|
||||||
return Array.isArray(props.activeId)
|
return Array.isArray(props.activeId)
|
||||||
? props.activeId.indexOf(id) !== -1
|
? props.activeId.includes(id)
|
||||||
: props.activeId === id;
|
: props.activeId === id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,13 +66,13 @@ export function unitToPx(value: string | number): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inBrowser) {
|
if (inBrowser) {
|
||||||
if (value.indexOf('rem') !== -1) {
|
if (value.includes('rem')) {
|
||||||
return convertRem(value);
|
return convertRem(value);
|
||||||
}
|
}
|
||||||
if (value.indexOf('vw') !== -1) {
|
if (value.includes('vw')) {
|
||||||
return convertVw(value);
|
return convertVw(value);
|
||||||
}
|
}
|
||||||
if (value.indexOf('vh') !== -1) {
|
if (value.includes('vh')) {
|
||||||
return convertVh(value);
|
return convertVh(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user