[Improvement] optimize isDef (#1109)

This commit is contained in:
neverland
2018-05-19 18:43:44 +08:00
committed by GitHub
parent 249e2400a3
commit d15efd756e
9 changed files with 5 additions and 28 deletions

View File

@@ -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));
}

View File

@@ -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>

View File

@@ -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();

View File

@@ -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;
}
},

View File

@@ -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() {

View File

@@ -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>

View File

@@ -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);

View File

@@ -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>

View File

@@ -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;
};