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>
|
<script>
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
import { isDef } from '../utils';
|
|
||||||
|
|
||||||
export default create({
|
export default create({
|
||||||
name: 'badge',
|
name: 'badge',
|
||||||
@ -33,8 +32,6 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isDef,
|
|
||||||
|
|
||||||
onClick() {
|
onClick() {
|
||||||
this.$emit('click', this.$parent.badges.indexOf(this));
|
this.$emit('click', this.$parent.badges.indexOf(this));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isDef } from '../utils';
|
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
|
|
||||||
export default create({
|
export default create({
|
||||||
@ -44,10 +43,6 @@ export default create({
|
|||||||
type: String,
|
type: String,
|
||||||
default: '¥'
|
default: '¥'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
isDef
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import { isDef } from '../utils';
|
|
||||||
import RouterLink from '../mixins/router-link';
|
import RouterLink from '../mixins/router-link';
|
||||||
import create from '../utils/create-basic';
|
import create from '../utils/create-basic';
|
||||||
|
|
||||||
@ -65,8 +64,6 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isDef,
|
|
||||||
|
|
||||||
onClick() {
|
onClick() {
|
||||||
this.$emit('click');
|
this.$emit('click');
|
||||||
this.routerLink();
|
this.routerLink();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
import { isDef } from '../utils';
|
|
||||||
import findParent from '../mixins/find-parent';
|
import findParent from '../mixins/find-parent';
|
||||||
|
|
||||||
export default create({
|
export default create({
|
||||||
@ -79,7 +78,7 @@ export default create({
|
|||||||
const { currentValue } = this;
|
const { currentValue } = this;
|
||||||
if ({}.toString.call(currentValue) === '[object Boolean]') {
|
if ({}.toString.call(currentValue) === '[object Boolean]') {
|
||||||
return currentValue;
|
return currentValue;
|
||||||
} else if (isDef(currentValue)) {
|
} else if (this.isDef(currentValue)) {
|
||||||
return currentValue === this.name;
|
return currentValue === this.name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import findParent from '../mixins/find-parent';
|
import findParent from '../mixins/find-parent';
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
import { isDef } from '../utils';
|
|
||||||
|
|
||||||
export default create({
|
export default create({
|
||||||
name: 'collapse-item',
|
name: 'collapse-item',
|
||||||
@ -39,7 +38,7 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
currentName() {
|
currentName() {
|
||||||
return isDef(this.name) ? this.name : this.index;
|
return this.isDef(this.name) ? this.name : this.index;
|
||||||
},
|
},
|
||||||
|
|
||||||
expanded() {
|
expanded() {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isDef } from '../utils';
|
|
||||||
import create from '../utils/create-basic';
|
import create from '../utils/create-basic';
|
||||||
|
|
||||||
export default create({
|
export default create({
|
||||||
@ -16,10 +15,6 @@ export default create({
|
|||||||
name: String,
|
name: String,
|
||||||
info: [String, Number],
|
info: [String, Number],
|
||||||
color: String
|
color: String
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
isDef
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isDef } from '../utils';
|
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
import RouterLink from '../mixins/router-link';
|
import RouterLink from '../mixins/router-link';
|
||||||
|
|
||||||
@ -43,8 +42,6 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isDef,
|
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
this.$parent.onChange(this.$parent.items.indexOf(this));
|
this.$parent.onChange(this.$parent.items.indexOf(this));
|
||||||
this.$emit('click', event);
|
this.$emit('click', event);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
import Popup from '../mixins/popup';
|
import Popup from '../mixins/popup';
|
||||||
import { isDef } from '../utils';
|
|
||||||
|
|
||||||
const STYLE_LIST = ['success', 'fail', 'loading'];
|
const STYLE_LIST = ['success', 'fail', 'loading'];
|
||||||
|
|
||||||
@ -51,10 +50,6 @@ export default create({
|
|||||||
displayStyle() {
|
displayStyle() {
|
||||||
return STYLE_LIST.indexOf(this.type) !== -1 ? 'default' : this.type;
|
return STYLE_LIST.indexOf(this.type) !== -1 ? 'default' : this.type;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
isDef
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import '../locale';
|
import '../locale';
|
||||||
import bem from '../mixins/bem';
|
import bem from '../mixins/bem';
|
||||||
import i18n from '../mixins/i18n';
|
import i18n from '../mixins/i18n';
|
||||||
|
import { isDef } from './';
|
||||||
|
|
||||||
const install = function(Vue) {
|
const install = function(Vue) {
|
||||||
Vue.component(this.name, this);
|
Vue.component(this.name, this);
|
||||||
@ -14,6 +15,8 @@ export default function(sfc) {
|
|||||||
sfc.install = sfc.install || install;
|
sfc.install = sfc.install || install;
|
||||||
sfc.mixins = sfc.mixins || [];
|
sfc.mixins = sfc.mixins || [];
|
||||||
sfc.mixins.push(i18n, bem);
|
sfc.mixins.push(i18n, bem);
|
||||||
|
sfc.methods = sfc.methods || {};
|
||||||
|
sfc.methods.isDef = isDef;
|
||||||
|
|
||||||
return sfc;
|
return sfc;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user