基于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工程全局設(shè)置ajax的等待動(dòng)效的方法
這篇文章主要介紹了vue工程全局設(shè)置ajax的等待動(dòng)效的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-02-02
vue實(shí)現(xiàn)復(fù)制文字復(fù)制圖片實(shí)例詳解
這篇文章主要為大家介紹了vue實(shí)現(xiàn)復(fù)制文字復(fù)制圖片實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
vue3響應(yīng)式轉(zhuǎn)換常用API操作示例代碼
在Vue 3中,響應(yīng)式系統(tǒng)得到了顯著改善,包括使用Composition API時(shí)更加靈活的狀態(tài)管理,這篇文章主要介紹了vue3響應(yīng)式轉(zhuǎn)換常用API操作示例代碼,需要的朋友可以參考下2024-08-08
Vue3 封裝 element-plus 圖標(biāo)選擇器實(shí)現(xiàn)步驟
這篇文章主要介紹了Vue3 封裝 element-plus 圖標(biāo)選擇器,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-09-09
Vue官方推薦AJAX組件axios.js使用方法詳解與API
axios是Vue官方推薦AJAX組件,下面為大家介紹axios.js庫(kù)的詳細(xì)使用方法與API介紹2018-10-10
vue實(shí)現(xiàn)新聞?wù)故卷?yè)的步驟詳解
最近小編遇到這樣的需求,要實(shí)現(xiàn)一個(gè)新聞?wù)故卷?yè)功能,剛接到這樣的需求還真是一頭霧水,不知從哪入手,今天小編通過(guò)實(shí)例代碼給大家介紹下vue實(shí)現(xiàn)新聞?wù)故卷?yè)的步驟詳解,感興趣的朋友跟隨小編一起看看吧2019-04-04
Vue?echarts@4.x中國(guó)地圖及AMap相關(guān)API使用詳解
這篇文章主要為大家介紹了Vue使用echarts@4.x中國(guó)地圖及AMap相關(guān)API使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12
vue3中調(diào)用api接口實(shí)現(xiàn)數(shù)據(jù)的渲染以及詳情方式
這篇文章主要介紹了vue3中調(diào)用api接口實(shí)現(xiàn)數(shù)據(jù)的渲染以及詳情方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
Vue導(dǎo)入excel文件的兩種方式(form表單和el-upload)
最近開(kāi)發(fā)遇到一個(gè)點(diǎn)擊導(dǎo)入按鈕讓excel文件數(shù)據(jù)導(dǎo)入的需求,下面這篇文章主要給大家介紹了關(guān)于Vue導(dǎo)入excel文件的兩種方式,分別是form表單和el-upload兩種方法,需要的朋友可以參考下2022-11-11

