Merge remote-tracking branch 'origin/master'
Showing
1 changed file
with
16 additions
and
15 deletions
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | }, | 68 | }, |
69 | data() { | 69 | data() { |
70 | return { | 70 | return { |
71 | - | 71 | + viewOption: {}, |
72 | btnSelected: false, | 72 | btnSelected: false, |
73 | actionClass: '', | 73 | actionClass: '', |
74 | editText: null | 74 | editText: null |
@@ -76,16 +76,17 @@ | @@ -76,16 +76,17 @@ | ||
76 | }, | 76 | }, |
77 | created() { | 77 | created() { |
78 | forEach(defaultOption, (value, key) => { | 78 | forEach(defaultOption, (value, key) => { |
79 | - if (!this.option.hasOwnProperty(key)) { | ||
80 | - this.option[key] = value; | 79 | + if (!this.viewOption.hasOwnProperty(key)) { |
80 | + this.viewOption[key] = this.option.hasOwnProperty(key) ? this.option[key] : defaultOption[key]; | ||
81 | } | 81 | } |
82 | }); | 82 | }); |
83 | + this.viewOption = {...this.viewOption}; | ||
83 | }, | 84 | }, |
84 | computed: { | 85 | computed: { |
85 | btnStyle() { | 86 | btnStyle() { |
86 | - let color = this.option.color || defaultOption.color; | 87 | + let color = this.viewOption.color || defaultOption.color; |
87 | 88 | ||
88 | - return `color: ${this.btnSelected ? (this.option.selectedColor || color) : color};`; | 89 | + return `color: ${this.btnSelected ? (this.viewOption.selectedColor || color) : color};`; |
89 | }, | 90 | }, |
90 | iconClass() { | 91 | iconClass() { |
91 | if (this.actionClass) { | 92 | if (this.actionClass) { |
@@ -97,7 +98,7 @@ | @@ -97,7 +98,7 @@ | ||
97 | this._icon = classMap[this._type]; | 98 | this._icon = classMap[this._type]; |
98 | } | 99 | } |
99 | 100 | ||
100 | - if (this.option.selected) { | 101 | + if (this.viewOption.selected) { |
101 | this.btnSelected = true; | 102 | this.btnSelected = true; |
102 | 103 | ||
103 | return this._icon.selected || this._icon.default; | 104 | return this._icon.selected || this._icon.default; |
@@ -106,25 +107,25 @@ | @@ -106,25 +107,25 @@ | ||
106 | return this._icon.default; | 107 | return this._icon.default; |
107 | }, | 108 | }, |
108 | iconStyle() { | 109 | iconStyle() { |
109 | - return `font-size: ${this.pxToRem(this.option.iconFontSize)};`; | 110 | + return `font-size: ${this.pxToRem(this.viewOption.iconFontSize)};`; |
110 | }, | 111 | }, |
111 | textStyle() { | 112 | textStyle() { |
112 | - let style = `font-size: ${this.pxToRem(this.option.textFontSize)};`; | 113 | + let style = `font-size: ${this.pxToRem(this.viewOption.textFontSize)};`; |
113 | 114 | ||
114 | - let textAlign = this.option.textAlign; | 115 | + let textAlign = this.viewOption.textAlign; |
115 | 116 | ||
116 | if (['top', 'bottom'].indexOf(textAlign) >= 0) { | 117 | if (['top', 'bottom'].indexOf(textAlign) >= 0) { |
117 | style += ` vertical-align: ${textAlign};`; | 118 | style += ` vertical-align: ${textAlign};`; |
118 | } | 119 | } |
119 | 120 | ||
120 | - let textZoom = this.option.textZoom; | 121 | + let textZoom = this.viewOption.textZoom; |
121 | 122 | ||
122 | if (Number(textZoom) !== NaN) { | 123 | if (Number(textZoom) !== NaN) { |
123 | style += ` transform: scale(${textZoom}, ${textZoom});` | 124 | style += ` transform: scale(${textZoom}, ${textZoom});` |
124 | } | 125 | } |
125 | 126 | ||
126 | - if (this.option.textSelectedColor) { | ||
127 | - style += ` color: ${this.option.textSelectedColor};` | 127 | + if (this.viewOption.textSelectedColor) { |
128 | + style += ` color: ${this.viewOption.textSelectedColor};` | ||
128 | } | 129 | } |
129 | 130 | ||
130 | return style; | 131 | return style; |
@@ -158,7 +159,7 @@ | @@ -158,7 +159,7 @@ | ||
158 | changeBtnStatus() { | 159 | changeBtnStatus() { |
159 | this.btnSelected = !this.btnSelected; | 160 | this.btnSelected = !this.btnSelected; |
160 | 161 | ||
161 | - if (this.option.textAutoChange) { | 162 | + if (this.viewOption.textAutoChange) { |
162 | let _text = this.editText || this.text; | 163 | let _text = this.editText || this.text; |
163 | 164 | ||
164 | if (!isNaN(Number(this.viewText))) { | 165 | if (!isNaN(Number(this.viewText))) { |
@@ -182,7 +183,7 @@ | @@ -182,7 +183,7 @@ | ||
182 | return; | 183 | return; |
183 | } | 184 | } |
184 | 185 | ||
185 | - if (this.option.canSelect) { | 186 | + if (this.viewOption.canSelect) { |
186 | this.changeBtnStatus(); | 187 | this.changeBtnStatus(); |
187 | 188 | ||
188 | let syncFnName = ''; | 189 | let syncFnName = ''; |
@@ -227,7 +228,7 @@ | @@ -227,7 +228,7 @@ | ||
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | - this.option.emitName && this.$emit(this.option.emitName, evt); | 231 | + this.viewOption.emitName && this.$emit(this.viewOption.emitName, evt); |
231 | } | 232 | } |
232 | }, | 233 | }, |
233 | }; | 234 | }; |
-
Please register or login to post a comment