微信小程序 自定義對話框?qū)嵗斀?/h1>
更新時間:2017年01月20日 17:16:20 投稿:lqh
這篇文章主要介紹了微信小程序 自定義對話框?qū)嵗斀獾南嚓P(guān)資料,這里附有實例代碼及實現(xiàn)效果圖,需要的朋友可以參考下
微信小程序 自定義對話框?qū)嵗斀?/strong>
效果圖:

index.wxml:
<button type="default" bindtap="clickbtn">
點擊
</button>
<view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view>
<view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}">
<!--對話框標(biāo)題-->
<view class="dialog-title">
請輸入內(nèi)容
</view>
<!--對話框輸入部分-->
<view class="input-view">
<input type="text" bindblur="input_content" class="input-style"/>
</view>
<!--對話框按鈕-->
<view class="line-top">
</view>
<view class="btn-view">
<view class="btn-cancel" bindtap="click_cancel">
取 消
</view>
<view class="btn-line">
</view>
<view class="btn-cancel" bindtap="click_ok">
確 定
</view>
</view>
</view>
index.js:
var inputinfo = "";
var app = getApp()
Page({
data: {
animationData:"",
showModalStatus:false
},
onLoad: function () {
},
showModal: function () {
// 顯示遮罩層
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
showModalStatus: true
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export()
})
}.bind(this), 200)
},
clickbtn:function(){
if(this.data.showModalStatus){
this.hideModal();
}else{
this.showModal();
}
},
hideModal: function () {
// 隱藏遮罩層
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
}.bind(this), 200)
},
click_cancel:function(){
console.log("點擊取消");
this.hideModal();
},
click_ok:function(){
console.log("點擊了確定===,輸入的信息為為==",inputinfo);
this.hideModal();
},
input_content:function(e){
console.log(e);
inputinfo = e.detail.value;
}
})
源碼下載:http://xiazai.jb51.net/201701/yuanma/modalTest(jb51.net).rar
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
-
TypeScript實用技巧?Nominal?Typing名義類型詳解
這篇文章主要為大家介紹了TypeScript實用技巧?Nominal?Typing名義類型詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪 2022-09-09
-
JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式
這篇文章主要為大家介紹了JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪 2022-09-09
-
關(guān)于JavaScript?中?if包含逗號表達(dá)式
這篇文章主要介紹了?關(guān)于JavaScript?中?if包含逗號表達(dá)式,有時會看到JavaScript中if判斷里包含英文逗號?“,”,這個是其實是逗號表達(dá)式。在if條件里,只有最后一個表達(dá)式起判斷作用。下面來看看文章的具體介紹吧 2021-11-11
最新評論
微信小程序 自定義對話框?qū)嵗斀?/strong>
效果圖:

index.wxml:
<button type="default" bindtap="clickbtn">
點擊
</button>
<view class="commodity_screen" bindtap="hideModal" wx:if="{{showModalStatus}}"></view>
<view animation="{{animationData}}" class="commodity_attr_box" wx:if="{{showModalStatus}}">
<!--對話框標(biāo)題-->
<view class="dialog-title">
請輸入內(nèi)容
</view>
<!--對話框輸入部分-->
<view class="input-view">
<input type="text" bindblur="input_content" class="input-style"/>
</view>
<!--對話框按鈕-->
<view class="line-top">
</view>
<view class="btn-view">
<view class="btn-cancel" bindtap="click_cancel">
取 消
</view>
<view class="btn-line">
</view>
<view class="btn-cancel" bindtap="click_ok">
確 定
</view>
</view>
</view>
index.js:
var inputinfo = "";
var app = getApp()
Page({
data: {
animationData:"",
showModalStatus:false
},
onLoad: function () {
},
showModal: function () {
// 顯示遮罩層
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
showModalStatus: true
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export()
})
}.bind(this), 200)
},
clickbtn:function(){
if(this.data.showModalStatus){
this.hideModal();
}else{
this.showModal();
}
},
hideModal: function () {
// 隱藏遮罩層
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(300).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
}.bind(this), 200)
},
click_cancel:function(){
console.log("點擊取消");
this.hideModal();
},
click_ok:function(){
console.log("點擊了確定===,輸入的信息為為==",inputinfo);
this.hideModal();
},
input_content:function(e){
console.log(e);
inputinfo = e.detail.value;
}
})
源碼下載:http://xiazai.jb51.net/201701/yuanma/modalTest(jb51.net).rar
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
TypeScript實用技巧?Nominal?Typing名義類型詳解
這篇文章主要為大家介紹了TypeScript實用技巧?Nominal?Typing名義類型詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式
這篇文章主要為大家介紹了JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
關(guān)于JavaScript?中?if包含逗號表達(dá)式
這篇文章主要介紹了?關(guān)于JavaScript?中?if包含逗號表達(dá)式,有時會看到JavaScript中if判斷里包含英文逗號?“,”,這個是其實是逗號表達(dá)式。在if條件里,只有最后一個表達(dá)式起判斷作用。下面來看看文章的具體介紹吧2021-11-11

