初步完成返回游戏功能,待测试完善
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, watch, onUnmounted } from "vue";
|
||||
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||
const props = defineProps({
|
||||
start: {
|
||||
type: Boolean,
|
||||
@@ -33,11 +33,14 @@ watch(
|
||||
(newVal) => {
|
||||
if (newVal.includes("红队")) barColor.value = "#FF6060";
|
||||
if (newVal.includes("蓝队")) barColor.value = "#5FADFF";
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.seq,
|
||||
() => [props.seq, props.total],
|
||||
() => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = props.total;
|
||||
@@ -77,7 +80,16 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
const updateRemain = (value) => {
|
||||
remain.value = Math.floor(value);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("update-ramain", updateRemain);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off("update-ramain", updateRemain);
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user