getComputedStyle在IE中不能正确获取元素的宽度,改为通过offsetWidth获取,修正tabs的高亮下划线在IE中错位的问题

This commit is contained in:
erhuluanzi 2017-08-06 16:25:43 +08:00
parent 06290cb3a9
commit 75798f5b0c

View file

@ -150,13 +150,13 @@
const index = this.navList.findIndex((nav) => nav.name === this.activeKey);
const prevTabs = this.$refs.nav.querySelectorAll(`.${prefixCls}-tab`);
const tab = prevTabs[index];
this.barWidth = parseFloat(getStyle(tab, 'width'));
this.barWidth = parseFloat(tab.offsetWidth);
if (index > 0) {
let offset = 0;
const gutter = this.size === 'small' ? 0 : 16;
for (let i = 0; i < index; i++) {
offset += parseFloat(getStyle(prevTabs[i], 'width')) + gutter;
offset += parseFloat(prevTabs[i].offsetWidth) + gutter;
}
this.barOffset = offset;