您的位置:首页 > 产品设计 > UI/UE

VUE Element UI 60秒倒计时

2017-12-28 10:36 567 查看
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>

<body>
<el-container id='app'>
<el-button @click="sendMsg" type="primary" :disabled="isDisabled">{{buttonName}}</el-button>
</el-table>
</el-container>
</body>
<!-- 先引入 Vue -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
new Vue({
el: '#app',
data: {
buttonName: "发送短信",
isDisabled: false,
time: 10
},
methods: {
sendMsg() {
let me = this;
me.isDisabled = true;
let interval = window.setInterval(function() {
me.buttonName = '(' + me.time + '秒)后重新发送';
--me.time;
if(me.time < 0) {
me.buttonName = "重新发送";
me.time = 10;
me.isDisabled = false;
window.clearInterval(interval);
}
}, 1000);

}

}

})
</script>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  VUE Element UI