mirror of
https://github.com/youzan/vant.git
synced 2025-10-14 07:00:32 +00:00
refactor: replace find method for improved readability (#13395)
This commit is contained in:
@@ -49,7 +49,7 @@ export const isOptionExist = (
|
||||
fields: Required<PickerFieldNames>,
|
||||
) =>
|
||||
value !== undefined &&
|
||||
!!options.find((option) => option[fields.value] === value);
|
||||
options.some((option) => option[fields.value] === value);
|
||||
|
||||
export function findOptionByValue(
|
||||
options: PickerOption[],
|
||||
|
@@ -59,7 +59,7 @@ export default defineComponent({
|
||||
const { $route } = vm;
|
||||
const { to } = props;
|
||||
const config = isObject(to) ? to : { path: to };
|
||||
return !!$route.matched.find((val) => {
|
||||
return $route.matched.some((val) => {
|
||||
const pathMatched = 'path' in config && config.path === val.path;
|
||||
const nameMatched = 'name' in config && config.name === val.name;
|
||||
return pathMatched || nameMatched;
|
||||
|
@@ -267,12 +267,11 @@ export default defineComponent({
|
||||
name: Numeric,
|
||||
skipScrollIntoView?: boolean,
|
||||
) => {
|
||||
const matched = children.find(
|
||||
const index = children.findIndex(
|
||||
(tab, index) => getTabName(tab, index) === name,
|
||||
);
|
||||
|
||||
const index = matched ? children.indexOf(matched) : 0;
|
||||
setCurrentIndex(index, skipScrollIntoView);
|
||||
setCurrentIndex(index === -1 ? 0 : index, skipScrollIntoView);
|
||||
};
|
||||
|
||||
const scrollToCurrentContent = (immediate = false) => {
|
||||
|
Reference in New Issue
Block a user