Skip to content

Commit

Permalink
fix: 修复eslint的错误和警告 (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
unfound committed Mar 20, 2022
1 parent 3d576d7 commit afb879b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 3 additions & 1 deletion packages/devui-vue/devui/select/hooks/use-cache-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { ComputedRef, computed } from 'vue';
import { OptionObjectItem } from '../src/use-select';
import { KeyType } from '../src/utils';

export default function (mergeOptions: ComputedRef<OptionObjectItem[]>): any {
type GetValueOptionFunc = (values: KeyType<OptionObjectItem, 'value'>[]) => (OptionObjectItem | undefined)[];

export default function (mergeOptions: ComputedRef<OptionObjectItem[]>): GetValueOptionFunc{
const cacheOptions = computed(() => {
const map = new Map<KeyType<OptionObjectItem, 'value'>, OptionObjectItem>();
mergeOptions.value.forEach((item) => {
Expand Down
8 changes: 2 additions & 6 deletions packages/devui-vue/devui/select/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import type { App } from 'vue';
import Select from './src/select';

Select.install = function(app: App) {
app.component(Select.name, Select);
};

export { Select };

export default {
title: 'Select 下拉框',
category: '数据录入',
status: '10%',
install(app: App): void {
app.use(Select as any);
}
app.component(Select.name, Select);
},
};
7 changes: 3 additions & 4 deletions packages/devui-vue/devui/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default defineComponent({
if (typeof item === 'object') {
option = {
name: item.name ? item.name : item.value + '',
value: item.value,
_checked: false,
...item,
};
Expand Down Expand Up @@ -64,7 +63,7 @@ export default defineComponent({
const inputValue = computed<string>(() => {
if (props.multiple && Array.isArray(props.modelValue)) {
const selectedOptions = getValuesOption(props.modelValue);
return selectedOptions.map((item) => item.name).join(',');
return selectedOptions.map((item) => item?.name || '').join(',');
} else if (!Array.isArray(props.modelValue)) {
return getValuesOption([props.modelValue])[0]?.name || '';
}
Expand All @@ -82,8 +81,8 @@ export default defineComponent({
if (multiple) {
item._checked = !item._checked;
modelValue = mergeOptions.value
.filter((item) => item._checked)
.map((item) => item.value);
.filter((item1) => item1._checked)
.map((item2) => item2.value);
ctx.emit('update:modelValue', modelValue);
} else {
ctx.emit('update:modelValue', item.value);
Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/devui/select/src/use-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface OptionObjectItem {
name: string;
value: string | number;
_checked: boolean;
[key: string]: any;
[key: string]: unknown;
}

export type OptionItem =
Expand Down

0 comments on commit afb879b

Please sign in to comment.