完成单组练习接口调试
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
const props = defineProps({
|
||||
start: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
tips: {
|
||||
type: String,
|
||||
default: "",
|
||||
@@ -10,18 +14,25 @@ const props = defineProps({
|
||||
default: 90,
|
||||
},
|
||||
});
|
||||
|
||||
let barColor = "#fed847";
|
||||
if (props.tips.includes("红队")) barColor = "#FF6060";
|
||||
if (props.tips.includes("蓝队")) barColor = "#5FADFF";
|
||||
const remain = ref(0);
|
||||
onMounted(() => {
|
||||
remain.value = props.total;
|
||||
setInterval(() => {
|
||||
if (remain.value > 0) {
|
||||
remain.value--;
|
||||
const remain = ref(props.total);
|
||||
|
||||
watch(
|
||||
() => props.start,
|
||||
(newVal, oldVal) => {
|
||||
if (oldVal === false && newVal === true) {
|
||||
remain.value = props.total;
|
||||
setInterval(() => {
|
||||
if (remain.value > 0) {
|
||||
remain.value--;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user