Commit 383e96a86aee71ffd11da67328583ba258a14e93

Authored by 梁灏
1 parent 154bb822

Tabs add global setting, #5592

src/components/tabs/tabs.vue
... ... @@ -19,7 +19,7 @@
19 19 <Icon v-if="item.icon !== ''" :type="item.icon"></Icon>
20 20 <Render v-if="item.labelType === 'function'" :render="item.label"></Render>
21 21 <template v-else>{{ item.label }}</template>
22   - <Icon v-if="showClose(item)" type="ios-close" @click.native.stop="handleRemove(index)"></Icon>
  22 + <Icon :class="[prefixCls + '-close']" v-if="showClose(item)" :type="arrowType" :custom="customArrowType" :size="arrowSize" @click.native.stop="handleRemove(index)"></Icon>
23 23 </div>
24 24 </div>
25 25 </div>
... ... @@ -169,6 +169,41 @@
169 169 }
170 170  
171 171 return style;
  172 + },
  173 + // 3.4.0, global setting customArrow 有值时,arrow 赋值空
  174 + arrowType () {
  175 + let type = 'ios-close';
  176 +
  177 + if (this.$IVIEW) {
  178 + if (this.$IVIEW.tabs.customCloseIcon) {
  179 + type = '';
  180 + } else if (this.$IVIEW.tabs.closeIcon) {
  181 + type = this.$IVIEW.tabs.closeIcon;
  182 + }
  183 + }
  184 + return type;
  185 + },
  186 + // 3.4.0, global setting
  187 + customArrowType () {
  188 + let type = '';
  189 +
  190 + if (this.$IVIEW) {
  191 + if (this.$IVIEW.tabs.customCloseIcon) {
  192 + type = this.$IVIEW.tabs.customCloseIcon;
  193 + }
  194 + }
  195 + return type;
  196 + },
  197 + // 3.4.0, global setting
  198 + arrowSize () {
  199 + let size = '';
  200 +
  201 + if (this.$IVIEW) {
  202 + if (this.$IVIEW.tabs.closeIconSize) {
  203 + size = this.$IVIEW.tabs.closeIconSize;
  204 + }
  205 + }
  206 + return size;
172 207 }
173 208 },
174 209 methods: {
... ...
src/index.js
... ... @@ -211,6 +211,11 @@ const install = function(Vue, opts = {}) {
211 211 icon: opts.timePicker ? opts.timePicker.icon ? opts.timePicker.icon : '' : '',
212 212 customIcon: opts.timePicker ? opts.timePicker.customIcon ? opts.timePicker.customIcon : '' : '',
213 213 iconSize: opts.timePicker ? opts.timePicker.iconSize ? opts.timePicker.iconSize : '' : ''
  214 + },
  215 + tabs: {
  216 + closeIcon: opts.tabs ? opts.tabs.closeIcon ? opts.tabs.closeIcon : '' : '',
  217 + customCloseIcon: opts.tabs ? opts.tabs.customCloseIcon ? opts.tabs.customCloseIcon : '' : '',
  218 + closeIconSize: opts.tabs ? opts.tabs.closeIconSize ? opts.tabs.closeIconSize : '' : ''
214 219 }
215 220 };
216 221  
... ...
src/styles/components/tabs.less
... ... @@ -203,7 +203,7 @@
203 203 &&-card > &-bar &-nav-wrap {
204 204 margin-bottom: 0;
205 205 }
206   - &&-card > &-bar &-tab .@{css-prefix-iconfont}-ios-close {
  206 + &&-card > &-bar &-tab &-close {
207 207 width: 0;
208 208 height: 22px;
209 209 font-size: 22px;
... ... @@ -221,8 +221,8 @@
221 221 }
222 222 }
223 223  
224   - &&-card > &-bar &-tab-active .@{css-prefix-iconfont}-ios-close,
225   - &&-card > &-bar &-tab:hover .@{css-prefix-iconfont}-ios-close {
  224 + &&-card > &-bar &-tab-active &-close,
  225 + &&-card > &-bar &-tab:hover &-close {
226 226 width: 22px;
227 227 transform: translateZ(0);
228 228 margin-right: -6px;
... ...