|
|
@ -95,21 +95,20 @@ export default { |
|
|
|
return activePath; |
|
|
|
return activePath; |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
beforeMount() { |
|
|
|
|
|
|
|
window.addEventListener('resize', this.setVisibleNumber) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
beforeDestroy() { |
|
|
|
|
|
|
|
window.removeEventListener('resize', this.setVisibleNumber) |
|
|
|
|
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
mounted() { |
|
|
|
this.setVisibleNumber(); |
|
|
|
this.setVisibleNumber(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
// 根据宽度计算设置显示栏数 |
|
|
|
// 根据宽度计算设置显示栏数 |
|
|
|
setVisibleNumber() { |
|
|
|
setVisibleNumber() { |
|
|
|
const width = document.body.getBoundingClientRect().width - 380; |
|
|
|
const width = document.body.getBoundingClientRect().width / 3; |
|
|
|
const elWidth = this.$el.getBoundingClientRect().width; |
|
|
|
this.visibleNumber = parseInt(width / 85); |
|
|
|
const menuItemNodes = this.$el.children; |
|
|
|
|
|
|
|
const menuWidth = Array.from(menuItemNodes).map( |
|
|
|
|
|
|
|
(i) => i.getBoundingClientRect().width |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
this.visibleNumber = ( |
|
|
|
|
|
|
|
parseInt(width - elWidth) / parseInt(menuWidth) |
|
|
|
|
|
|
|
).toFixed(0); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 菜单选择事件 |
|
|
|
// 菜单选择事件 |
|
|
|
handleSelect(key, keyPath) { |
|
|
|
handleSelect(key, keyPath) { |
|
|
|