update 优化 !pr417 解决部分问题 支持vue3版本

This commit is contained in:
疯狂的狮子Li 2023-09-08 17:41:14 +08:00
parent 3b498c4939
commit f2200df15a
2 changed files with 18 additions and 22 deletions

View File

@ -41,34 +41,30 @@ const props = defineProps({
type: Boolean,
default: true,
},
separator: {
type: String,
default: ",",
}
});
const values = computed(() => {
if (props.value !== null && typeof props.value !== 'undefined') {
return Array.isArray(props.value) ? props.value : [String(props.value)];
} else {
return [];
}
if (props.value === null || typeof props.value === 'undefined' || props.value === '') return [];
return Array.isArray(props.value) ? props.value.map(item => '' + item) : String(props.value).split(props.separator);
});
const unmatch = computed(() => {
unmatchArray.value = [];
if (props.value !== null && typeof props.value !== "undefined") {
//
if (!Array.isArray(props.value)) {
if (props.options.some((v) => v.value == props.value)) return false;
unmatchArray.value.push(props.value);
return true;
}
// Array
props.value.forEach((item) => {
if (!props.options.some((v) => v.value == item))
unmatchArray.value.push(item);
});
return true;
}
// value
return false;
if (props.value === null || typeof props.value === 'undefined' || props.value === '' || props.options.length === 0) return false
//
let unmatch = false //
values.value.forEach(item => {
if (!props.options.some(v => v.value === item)) {
unmatchArray.value.push(item)
unmatch = true // true
}
})
return unmatch //
});
function handleArray(array) {

View File

@ -53,13 +53,13 @@ export default {
},
computed: {
values() {
if (this.value === null || typeof this.value !== 'undefined' || this.value === '') return []
if (this.value === null || typeof this.value === 'undefined' || this.value === '') return []
return Array.isArray(this.value) ? this.value.map(item => '' + item) : String(this.value).split(this.separator)
},
unmatch() {
this.unmatchArray = []
// value
if (this.value === null || typeof this.value !== 'undefined' || this.value === '' || this.options.length === 0) return false
if (this.value === null || typeof this.value === 'undefined' || this.value === '' || this.options.length === 0) return false
//
let unmatch = false //
this.values.forEach(item => {