// 父组件执行该组件的countDown() 实现倒计时 const countDownButton = { template: ` {{ flag? name : num + lang.second_try}} `, data() { return { num: 60, flag: true, timer: null, }; }, props: { myClass: { type: String, default: "count-down-btn", }, name: { type: String, default: lang.send_code, }, loading: { type: Boolean, default: false, }, }, created() {}, methods: { countDown() { this.flag = false; this.num = --this.num; this.timer = setInterval(() => { if (this.num > 1) { this.flag = false; this.num = --this.num; } else { clearInterval(this.timer); this.timer = null; this.flag = true; this.num = 60; this.$emit("countend"); } }, 1000); }, }, };