mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] optimize isDef (#1109)
This commit is contained in:
parent
249e2400a3
commit
d15efd756e
@ -11,7 +11,6 @@
|
||||
|
||||
<script>
|
||||
import create from '../utils/create';
|
||||
import { isDef } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'badge',
|
||||
@ -33,8 +32,6 @@ export default create({
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef,
|
||||
|
||||
onClick() {
|
||||
this.$emit('click', this.$parent.badges.indexOf(this));
|
||||
}
|
||||
|
@ -27,7 +27,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isDef } from '../utils';
|
||||
import create from '../utils/create';
|
||||
|
||||
export default create({
|
||||
@ -44,10 +43,6 @@ export default create({
|
||||
type: String,
|
||||
default: '¥'
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
<script>
|
||||
import Icon from '../icon';
|
||||
import { isDef } from '../utils';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
import create from '../utils/create-basic';
|
||||
|
||||
@ -65,8 +64,6 @@ export default create({
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef,
|
||||
|
||||
onClick() {
|
||||
this.$emit('click');
|
||||
this.routerLink();
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
<script>
|
||||
import create from '../utils/create';
|
||||
import { isDef } from '../utils';
|
||||
import findParent from '../mixins/find-parent';
|
||||
|
||||
export default create({
|
||||
@ -79,7 +78,7 @@ export default create({
|
||||
const { currentValue } = this;
|
||||
if ({}.toString.call(currentValue) === '[object Boolean]') {
|
||||
return currentValue;
|
||||
} else if (isDef(currentValue)) {
|
||||
} else if (this.isDef(currentValue)) {
|
||||
return currentValue === this.name;
|
||||
}
|
||||
},
|
||||
|
@ -17,7 +17,6 @@
|
||||
<script>
|
||||
import findParent from '../mixins/find-parent';
|
||||
import create from '../utils/create';
|
||||
import { isDef } from '../utils';
|
||||
|
||||
export default create({
|
||||
name: 'collapse-item',
|
||||
@ -39,7 +38,7 @@ export default create({
|
||||
},
|
||||
|
||||
currentName() {
|
||||
return isDef(this.name) ? this.name : this.index;
|
||||
return this.isDef(this.name) ? this.name : this.index;
|
||||
},
|
||||
|
||||
expanded() {
|
||||
|
@ -6,7 +6,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isDef } from '../utils';
|
||||
import create from '../utils/create-basic';
|
||||
|
||||
export default create({
|
||||
@ -16,10 +15,6 @@ export default create({
|
||||
name: String,
|
||||
info: [String, Number],
|
||||
color: String
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -13,7 +13,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isDef } from '../utils';
|
||||
import create from '../utils/create';
|
||||
import RouterLink from '../mixins/router-link';
|
||||
|
||||
@ -43,8 +42,6 @@ export default create({
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef,
|
||||
|
||||
onClick(event) {
|
||||
this.$parent.onChange(this.$parent.items.indexOf(this));
|
||||
this.$emit('click', event);
|
||||
|
@ -18,7 +18,6 @@
|
||||
<script>
|
||||
import create from '../utils/create';
|
||||
import Popup from '../mixins/popup';
|
||||
import { isDef } from '../utils';
|
||||
|
||||
const STYLE_LIST = ['success', 'fail', 'loading'];
|
||||
|
||||
@ -51,10 +50,6 @@ export default create({
|
||||
displayStyle() {
|
||||
return STYLE_LIST.indexOf(this.type) !== -1 ? 'default' : this.type;
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
isDef
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -4,6 +4,7 @@
|
||||
import '../locale';
|
||||
import bem from '../mixins/bem';
|
||||
import i18n from '../mixins/i18n';
|
||||
import { isDef } from './';
|
||||
|
||||
const install = function(Vue) {
|
||||
Vue.component(this.name, this);
|
||||
@ -14,6 +15,8 @@ export default function(sfc) {
|
||||
sfc.install = sfc.install || install;
|
||||
sfc.mixins = sfc.mixins || [];
|
||||
sfc.mixins.push(i18n, bem);
|
||||
sfc.methods = sfc.methods || {};
|
||||
sfc.methods.isDef = isDef;
|
||||
|
||||
return sfc;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user