這篇文章給大家介紹怎么在微信小程序中實(shí)現(xiàn)一個(gè)表單彈窗,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

目前創(chuàng)新互聯(lián)已為數(shù)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、網(wǎng)站運(yùn)營(yíng)、企業(yè)網(wǎng)站設(shè)計(jì)、嶺東網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶(hù)導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶(hù)和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
WXML代碼如何:
<!--button-->
<view class="btn" bindtap="powerDrawer" data-statu="open">button</view>
<!--mask-->
<view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>
<!--content-->
<!--使用animation屬性指定需要執(zhí)行的動(dòng)畫(huà)-->
<view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}">
<!--drawer content-->
<view class="drawer_title">彈窗標(biāo)題</view>
<view class="drawer_content">
<view class="top grid">
<label class="title col-0">標(biāo)題</label>
<input class="input_base input_h40 col-1" name="rName" value="可自行定義內(nèi)容"></input>
</view>
<view class="top grid">
<label class="title col-0">標(biāo)題</label>
<input class="input_base input_h40 col-1" name="mobile" value="110"></input>
</view>
<view class="top grid">
<label class="title col-0">標(biāo)題</label>
<input class="input_base input_h40 col-1" name="phone" value="拒絕伸手黨"></input>
</view>
<view class="top grid">
<label class="title col-0">標(biāo)題</label>
<input class="input_base input_h40 col-1" name="Email" value="僅供學(xué)習(xí)使用"></input>
</view>
<view class="top bottom grid">
<label class="title col-0">備注</label>
<input class="input_base input_h40 col-1" name="bz"></input>
</view>
</view>
<view class="btn_ok" bindtap="powerDrawer" data-statu="close">確定</view>
</view>JS代碼如何:
Page({
data: {
showModalStatus: false
},
powerDrawer: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
this.util(currentStatu)
},
util: function(currentStatu){
/* 動(dòng)畫(huà)部分 */
// 第1步:創(chuàng)建動(dòng)畫(huà)實(shí)例
var animation = wx.createAnimation({
duration: 200, //動(dòng)畫(huà)時(shí)長(zhǎng)
timingFunction: "linear", //線性
delay: 0 //0則不延遲
});
// 第2步:這個(gè)動(dòng)畫(huà)實(shí)例賦給當(dāng)前的動(dòng)畫(huà)實(shí)例
this.animation = animation;
// 第3步:執(zhí)行第一組動(dòng)畫(huà)
animation.opacity(0).rotateX(-100).step();
// 第4步:導(dǎo)出動(dòng)畫(huà)對(duì)象賦給數(shù)據(jù)對(duì)象儲(chǔ)存
this.setData({
animationData: animation.export()
})
// 第5步:設(shè)置定時(shí)器到指定時(shí)候后,執(zhí)行第二組動(dòng)畫(huà)
setTimeout(function () {
// 執(zhí)行第二組動(dòng)畫(huà)
animation.opacity(1).rotateX(0).step();
// 給數(shù)據(jù)對(duì)象儲(chǔ)存的第一組動(dòng)畫(huà),更替為執(zhí)行完第二組動(dòng)畫(huà)的動(dòng)畫(huà)對(duì)象
this.setData({
animationData: animation
})
//關(guān)閉
if (currentStatu == "close") {
this.setData(
{
showModalStatus: false
}
);
}
}.bind(this), 200)
// 顯示
if (currentStatu == "open") {
this.setData(
{
showModalStatus: true
}
);
}
}
})WXSS代碼如何:
/*button*/
.btn {
width: 80%;
padding: 20rpx 0;
border-radius: 10rpx;
text-align: center;
margin: 40rpx 10%;
background: #000;
color: #fff;
}
/*mask*/
.drawer_screen {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
background: #000;
opacity: 0.5;
overflow: hidden;
}
/*content*/
.drawer_box {
width: 650rpx;
overflow: hidden;
position: fixed;
top: 50%;
left: 0;
z-index: 1001;
background: #FAFAFA;
margin: -150px 50rpx 0 50rpx;
border-radius: 3px;
}
.drawer_title{
padding:15px;
font: 20px "microsoft yahei";
text-align: center;
}
.drawer_content {
height: 210px;
overflow-y: scroll; /*超出父盒子高度可滾動(dòng)*/
}
.btn_ok{
padding: 10px;
font: 20px "microsoft yahei";
text-align: center;
border-top: 1px solid #E8E8EA;
color: #3CC51F;
}
.top{
padding-top:8px;
}
.bottom {
padding-bottom:8px;
}
.title {
height: 30px;
line-height: 30px;
width: 160rpx;
text-align: center;
display: inline-block;
font: 300 28rpx/30px "microsoft yahei";
}
.input_base {
border: 2rpx solid #ccc;
padding-left: 10rpx;
margin-right: 50rpx;
}
.input_h40{
height: 30px;
line-height: 30px;
}
.input_h70{
height: 60px;
}
.input_view{
font: 12px "microsoft yahei";
background: #fff;
color:#000;
line-height: 30px;
}
input {
font: 12px "microsoft yahei";
background: #fff;
color:#000 ;
}
radio{
margin-right: 20px;
}
.grid { display: -webkit-box; display: box; }
.col-0 {-webkit-box-flex:0;box-flex:0;}
.col-1 {-webkit-box-flex:1;box-flex:1;}
.fl { float: left;}
.fr { float: right;}關(guān)于怎么在微信小程序中實(shí)現(xiàn)一個(gè)表單彈窗就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
網(wǎng)站欄目:怎么在微信小程序中實(shí)現(xiàn)一個(gè)表單彈窗
文章來(lái)源:http://chinadenli.net/article40/gejcho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、域名注冊(cè)、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)站營(yíng)銷(xiāo)、企業(yè)網(wǎng)站制作、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)