Showing
1 changed file
with
8 additions
and
8 deletions
| ... | @@ -64,7 +64,7 @@ const onHeightChange = ({ height }) => { // 监听高度变化 | ... | @@ -64,7 +64,7 @@ const onHeightChange = ({ height }) => { // 监听高度变化 |
| 64 | } | 64 | } |
| 65 | // 添加可滚动高度 | 65 | // 添加可滚动高度 |
| 66 | if (height === (0.2 * window.innerHeight)) { | 66 | if (height === (0.2 * window.innerHeight)) { |
| 67 | - let str = $('.audio-item').height() * audio_list.value.length; | 67 | + let str = $('.audio-item').outerHeight() * (audio_list.value.length + 1.25); |
| 68 | $('.audio-list').css('marginBottom', `${str}px`); | 68 | $('.audio-list').css('marginBottom', `${str}px`); |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| ... | @@ -81,9 +81,11 @@ watch( | ... | @@ -81,9 +81,11 @@ watch( |
| 81 | if (v) { | 81 | if (v) { |
| 82 | // 自动打开第一个 | 82 | // 自动打开第一个 |
| 83 | handleAudioPlay(audio_list.value[0], 0); | 83 | handleAudioPlay(audio_list.value[0], 0); |
| 84 | - // 添加可滚动高度 | 84 | + nextTick(() => { |
| 85 | - let str = $('.audio-item').height() * audio_list.value.length; | 85 | + // 添加可滚动高度 |
| 86 | - $('.audio-list').css('marginBottom', `${str}px`); | 86 | + let str = $('.audio-item').outerHeight() * (audio_list.value.length + 1.25); |
| 87 | + $('.audio-list').css('marginBottom', `${str}px`); | ||
| 88 | + }) | ||
| 87 | } else { | 89 | } else { |
| 88 | onClose(); | 90 | onClose(); |
| 89 | } | 91 | } |
| ... | @@ -251,10 +253,8 @@ const handleAudioPlay = (item, index) => { | ... | @@ -251,10 +253,8 @@ const handleAudioPlay = (item, index) => { |
| 251 | console.log('Operation is too fast, audio play fails') | 253 | console.log('Operation is too fast, audio play fails') |
| 252 | }) | 254 | }) |
| 253 | } | 255 | } |
| 254 | - if (index) { | 256 | + // 指定滚动到播放位置 |
| 255 | - // 指定滚动到播放位置 | 257 | + scrollToId(index); |
| 256 | - scrollToId(index); | ||
| 257 | - } | ||
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | const scrollToId = (index) => { // 滚动到指定元素 | 260 | const scrollToId = (index) => { // 滚动到指定元素 | ... | ... |
-
Please register or login to post a comment