Skip to content

Commit faa0086

Browse files
committed
update: 修改摇一摇销毁逻辑
1 parent fac1d3b commit faa0086

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

platforms/app-plus/shake/shake.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
</view>
99
</view>
1010
</template>
11-
<script>
12-
let music = uni.createInnerAudioContext();
11+
<script>
1312
export default {
1413
data() {
1514
return {
@@ -19,13 +18,14 @@
1918
}
2019
},
2120
onLoad: function () {
22-
music.src = 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/shake/shake.wav';
21+
this.music = uni.createInnerAudioContext();
22+
this.music.src = 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/shake/shake.wav';
2323
2424
let index = 1,
2525
t = null;
2626
uni.onAccelerometerChange((res) => {
2727
if (Math.abs(res.x) + Math.abs(res.y) + Math.abs(res.z) > 20 && !this.show && this.isOpened) {
28-
music.play();
28+
this.music.play();
2929
setTimeout(() => {
3030
index++;
3131
if (index > 4) {
@@ -51,7 +51,7 @@
5151
this.show = false;
5252
this.isOpened = false;
5353
uni.stopAccelerometer();
54-
music.destroy();
54+
this.music.destroy();
5555
}
5656
}
5757
</script>

0 commit comments

Comments
 (0)