42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const _sfc_main = {
|
|
__name: "testsix",
|
|
setup(__props) {
|
|
const showButton = common_vendor.ref(true);
|
|
const countdownTime = common_vendor.ref(10);
|
|
const countdownText = common_vendor.computed(() => {
|
|
const minutes = Math.floor(countdownTime.value / 60).toString().padStart(2, "0");
|
|
const seconds = (countdownTime.value % 60).toString().padStart(2, "0");
|
|
return `点击我 (${minutes}:${seconds})`;
|
|
});
|
|
let intervalId;
|
|
common_vendor.onMounted(() => {
|
|
intervalId = setInterval(() => {
|
|
if (countdownTime.value > 0) {
|
|
countdownTime.value--;
|
|
} else {
|
|
clearInterval(intervalId);
|
|
showButton.value = false;
|
|
}
|
|
}, 1e3);
|
|
});
|
|
common_vendor.onUnmounted(() => {
|
|
clearInterval(intervalId);
|
|
});
|
|
const handleClick = () => {
|
|
alert("按钮被点击了!");
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: showButton.value
|
|
}, showButton.value ? {
|
|
b: common_vendor.t(countdownText.value),
|
|
c: common_vendor.o(handleClick)
|
|
} : {});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4c1535d3"]]);
|
|
my.createPage(MiniProgramPage);
|