[improvement] optimize watch options (#4075)

This commit is contained in:
neverland
2019-08-09 11:54:42 +08:00
committed by GitHub
parent 854a91c384
commit 19cd2ed38e
12 changed files with 19 additions and 57 deletions
+4 -9
View File
@@ -35,21 +35,16 @@ export default createComponent({
},
mounted() {
this.getWidth();
this.setWidth();
},
watch: {
showPivot() {
this.getWidth();
},
pivotText() {
this.getWidth();
}
showPivot: 'setWidth',
pivotText: 'setWidth'
},
methods: {
getWidth() {
setWidth() {
this.$nextTick(() => {
this.progressWidth = this.$el.offsetWidth;
this.pivotWidth = this.$refs.pivot ? this.$refs.pivot.offsetWidth : 0;