[Improvement] optimize utils (#661)

This commit is contained in:
neverland
2018-03-02 14:39:26 +08:00
committed by GitHub
parent 39cdaf0907
commit 92b116c071
7 changed files with 24 additions and 22 deletions

View File

@@ -25,7 +25,7 @@
</template>
<script>
import { create } from '../utils';
import { create, isObj } from '../utils';
const DEFAULT_DURATION = 200;
const range = (num, arr) => Math.min(Math.max(num, arr[0]), arr[1]);
@@ -147,11 +147,11 @@ export default create({
},
isDisabled(option) {
return typeof option === 'object' && option.disabled;
return isObj(option) && option.disabled;
},
getOptionText(option) {
return typeof option === 'object' && this.valueKey in option ? option[this.valueKey] : option;
return isObj(option) && this.valueKey in option ? option[this.valueKey] : option;
},
setIndex(index, userAction) {