-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
Description
Element UI version
2.4.6
OS/Browsers version
mac nw
Vue version
2.5.16
Reproduction Link
Steps to reproduce
说下bug原因:
// table-store.js
TableStore.prototype.mutations = function() {
Vue.nextTick(() => this.table.updateScrollY());
}
// table.vue
data() {
const store = new TableStore(this, {
rowKey: this.rowKey,
defaultExpandAll: this.defaultExpandAll,
selectOnIndeterminate: this.selectOnIndeterminate
});
const layout = new TableLayout({
store,
table: this,
fit: this.fit,
showHeader: this.showHeader
});
return {
layout,
store,
isHidden: false,
renderExpanded: null,
resizeProxyVisible: false,
resizeState: {
width: null,
height: null
},
// 是否拥有多级表头
isGroup: false,
scrollPosition: 'left'
};
}
// table-layout.js
updateColumnsWidth() {
if (Vue.prototype.$isServer) return;
const fit = this.fit;
const bodyWidth = this.table.$el.clientWidth;
// bug出现在这里 $el 为 undefind
}
问题就在于Vue.nextTick调用updateColumnsWidth时,vue还没有mounted,此时this.table.$el不存在,this.table.$el.clientWidth为报错
What is Expected?
ok
What is actually happening?
bug