vue.js實(shí)現(xiàn)簡單計(jì)時器功能
更新時間:2021年08月06日 11:26:26 作者:chaodaibing
這篇文章主要為大家詳細(xì)介紹了vue.js實(shí)現(xiàn)簡單計(jì)時器功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了vue.js實(shí)現(xiàn)簡單計(jì)時器功能的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html>
<html lang="en">
<head>
<title>抬腿計(jì)數(shù)器</title>
<script src="/static/vue/vue.js"></script>
<script src="/static/vue/index.js"></script>
<script src="/static/vue/vue-resource.min.js"></script>
<link rel="stylesheet" href="/static/vue/index.css" >
</head>
<style type="text/css">
.el-container {
margin:100px 30px 30px 30px ;
height:1800px;
background-color: #B3C0D1;
}
.el-button{
height:1800px;
width:100%;
font-size:300px;
}
</style>
<body>
<div id="app">
<el-container>
<el-button type="primary" :disabled="!canclick" @click="add">
{{ num }} <el-divider></el-divider> {{ content }}
</el-button>
</el-container>
<video ref="notify">
<source src="countdown.m4a" />
</video>
</div>
<script>
new Vue({
el: '#app',
data: function () {
return {
num:0,
canclick:true,
content:"計(jì)數(shù)器",
count:10
}
},
mounted(){
this.getnum() //獲取所有選擇項(xiàng)
},
methods:{
getnum:function(){
this.$http.get('/api/count/count.php').then(function(res){
this.num=res.data
},function(){
console.log('請求失敗處理')
});
},
add:function(){
this.canclick=false
this.$refs.notify.play()
this.content=this.count+'s后結(jié)束'
let clock=setInterval(()=>{
this.count--
this.content=this.count+'s后結(jié)束'
if(this.count==0){
this.content="計(jì)數(shù)器"
clearInterval(clock)
this.canclick=true
this.count=10
}
},850);
this.$http.get('/api/count/add.php?num='+this.num).then(function(res){
this.num=res.data
},function(){
console.log('請求失敗處理')
});
}
}
})
</script>
</body>
</html>
效果如下


以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 基于Vue方法實(shí)現(xiàn)簡單計(jì)時器
- 使用vue實(shí)現(xiàn)計(jì)時器功能
- vue實(shí)現(xiàn)簡易計(jì)時器組件
- vue計(jì)時器的實(shí)現(xiàn)方法
- Vue計(jì)時器的用法詳解
- 解決vue組件銷毀之后計(jì)時器繼續(xù)執(zhí)行的問題
- 在Vue環(huán)境下利用worker運(yùn)行interval計(jì)時器的步驟
- Vue 使用計(jì)時器實(shí)現(xiàn)跑馬燈效果的實(shí)例代碼
- vue 計(jì)時器組件的實(shí)現(xiàn)代碼
- Vue.js實(shí)現(xiàn)簡單計(jì)時器應(yīng)用
相關(guān)文章
antdv vue upload自定義上傳結(jié)合表單提交方式
這篇文章主要介紹了antdv vue upload自定義上傳結(jié)合表單提交方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10
Vue3導(dǎo)入Elementplus時組件無法加載的情況及解決
這篇文章主要介紹了Vue3導(dǎo)入Elementplus時組件無法加載的情況及解決方案,具有很好的參考價值,希望對大家有所幫助2024-03-03

