基于Vue實(shí)現(xiàn)我的錢(qián)包充值功能的示例代碼
要求:點(diǎn)擊充值按鈕彈出彈窗,點(diǎn)擊相應(yīng)彈窗中的確認(rèn)按鈕可進(jìn)行相應(yīng)充值,點(diǎn)擊取消彈窗隱藏
頁(yè)面效果
實(shí)現(xiàn)代碼
html部分
<template> <!-- 導(dǎo)航欄 --> <div> <van-nav-bar title="我的錢(qián)包" @click-left="onClickLeft" left-arrow> <template #right> <van-icon name="search" size="18" /> </template> </van-nav-bar> </div> <!-- 總資產(chǎn) --> <div class="money"> <van-row justify="space-around"> <van-col span="7"> <van-row> <van-col span="24">總資產(chǎn)(元)</van-col> <van-col span="24">{{ detailmoney }}</van-col> //插值語(yǔ)法 </van-row> </van-col> <van-col span="7"> <van-col span="24">累計(jì)充值(元)</van-col> <van-col span="24">{{ parply }}</van-col> </van-col> <van-col span="7"> <van-col span="24">累計(jì)消費(fèi)(元)</van-col> <van-col span="24">{{consume}}</van-col> </van-col> </van-row> </div> <!-- 充值 --> <div class="chong"> <van-row> <van-col span="13">充值¥100贈(zèng)送¥10</van-col> <van-col span="5" offset="5"> <div class="chong1" @click="chongzhi">充值</div> </van-col> </van-row> <van-row> <van-col span="24" style="height: 20px"></van-col> <van-col span="13">充值¥1贈(zèng)送¥1000</van-col> <van-col span="5" offset="5"> <div class="chong1" @click="chongzhi1">充值</div> </van-col> </van-row> <!-- 彈窗 --> <van-dialog v-model:show="show" title="充值" show-cancel-button @confirm="confirmFn" @cancel="cancelFn" confirmButtonText="確認(rèn)"> <p>確定充值</p > </van-dialog> </div> </template>
css樣式部分
<style> .money { background-color: rgb(67, 64, 64); height: 80px; border-radius: 10px; color: white; line-height: 40px; text-align: center; margin-top: 10px; } .chong { text-align: center; margin-top: 10px; padding: 20px; border: 1px solid rgb(235, 229, 229); } .chong1 { border-radius: 15px; background-color: rgb(219, 8, 8); color: white; }
script方法部分
export default { data() { return { allmoney:5048.22, //自行編寫(xiě)數(shù)據(jù) parply:2488.33, consume:6680.09, show:false, //設(shè)定初始值 money:false //資產(chǎn)的變動(dòng) } }, // 限制溢出 computed:{ detailmoney(){ return this.allmoney.toFixed(2) //保留后兩位 } }, methods: { chongzhi(){ //充值按鈕 this.show=true //彈窗是否顯示 this.money=true //第一個(gè)按鈕為true }, chongzhi1(){ this.show=true this.money=false//第二個(gè)按鈕為false }, confirmFn(){ //確認(rèn)按鈕 if(this.money){ //判斷:如果為true執(zhí)行第一個(gè),為false執(zhí)行第二個(gè) this.allmoney=this.allmoney+110 this.parply=this.parply+110 }else{ this.allmoney=this.allmoney+1001 this.parply=this.parply+1001 } }, onClickLeft() { //頭部返回按鈕 this.$router.push('/my') }, } }
到此這篇關(guān)于基于Vue實(shí)現(xiàn)我的錢(qián)包充值功能的示例代碼的文章就介紹到這了,更多相關(guān)Vue充值內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue開(kāi)發(fā)實(shí)現(xiàn)評(píng)論列表
這篇文章主要為大家詳細(xì)介紹了vue開(kāi)發(fā)實(shí)現(xiàn)評(píng)論列表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04Vuejs中的watch實(shí)例詳解(監(jiān)聽(tīng)者)
本文通過(guò)實(shí)例代碼給大家介紹了Vuejs中的watch,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-01-01快速解決vue2+vue-cli3項(xiàng)目ie兼容的問(wèn)題
這篇文章主要介紹了快速解決vue2+vue-cli3項(xiàng)目ie兼容的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-11-11Vue的異步組件加載的實(shí)現(xiàn)方法小結(jié)
在 Vue 中,異步組件是指那些在需要時(shí)才會(huì)被加載的組件,與傳統(tǒng)的靜態(tài)組件不同,異步組件通過(guò)動(dòng)態(tài)加載的方式,可以有效地減少初始加載的資源和時(shí)間,在 Vue 中實(shí)現(xiàn)異步組件加載非常簡(jiǎn)單,開(kāi)發(fā)者有多種方法可以做到,本文給大家介紹了一些常用的實(shí)現(xiàn)方法2024-11-11vue自定義移動(dòng)端touch事件之點(diǎn)擊、滑動(dòng)、長(zhǎng)按事件
這篇文章主要介紹了vue自定義移動(dòng)端touch事件之點(diǎn)擊、滑動(dòng)、長(zhǎng)按事件的實(shí)例代碼,需要的朋友可以參考下2018-07-07vue使用openlayers實(shí)現(xiàn)移動(dòng)點(diǎn)動(dòng)畫(huà)
這篇文章主要為大家詳細(xì)介紹了vue使用openlayers實(shí)現(xiàn)移動(dòng)點(diǎn)動(dòng)畫(huà),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-09-09vue3中通過(guò)ref獲取元素節(jié)點(diǎn)的實(shí)現(xiàn)
這篇文章主要介紹了vue3中通過(guò)ref獲取元素節(jié)點(diǎn)的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-07-07在vue中實(shí)現(xiàn)iframe嵌套Html頁(yè)面及注意事項(xiàng)說(shuō)明
這篇文章主要介紹了在vue中實(shí)現(xiàn)iframe嵌套Html頁(yè)面及注意事項(xiàng)說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10