修复宽度计算问题

pull/930/merge
lyswhut 2022-02-17 15:48:55 +08:00
parent 78ae89199e
commit f7edd54ea7
1 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,5 @@
<template lang="pug">
div.comment(:class="$style.comment")
div.comment(:class="$style.comment" ref="dom_container")
div(:class="$style.commentHeader")
h3 {{$t('comment__title', { name: title })}}
div(:class="$style.commentHeaderBtns")
@ -117,12 +117,22 @@ export default {
: '^-^'
},
},
mounted() {
this.setWidth()
window.addEventListener('resize', this.setWidth)
},
beforeUnmount() {
window.removeEventListener('resize', this.setWidth)
},
watch: {
show(n) {
if (n) this.handleShowComment()
},
},
methods: {
setWidth() {
this.$refs.dom_container.style.width = this.$refs.dom_container.clientWidth + 'px'
},
async getComment(musicInfo, page, limit, retryNum = 0) {
let resp
try {