微信小程序 Toast自定義實例詳解
更新時間:2017年01月20日 17:04:57 投稿:lqh
這篇文章主要介紹了微信小程序 Toast自定義實例詳解的相關(guān)資料,需要的朋友可以參考下
微信小程序 Toast自定義實例詳解
實現(xiàn)類似于Android的Toast提示
index.js:
var timer;
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(200).step()
this.setData({
animationData: animation.export(),
showModalStatus: true
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export()
})
}.bind(this), 200)
console.log("準備執(zhí)行");
timer = setTimeout(function () {
if(this.data.showModalStatus){
this.hideModal();
console.log("是否執(zhí)行");
}
}.bind(this), 3000)
},
clickbtn:function(){
if(this.data.showModalStatus){
this.hideModal();
}else{
this.showModal();
}
},
hideModal: function () {
if(timer != null){
clearTimeout(timer);
timer = null;
}
// 隱藏遮罩層
var animation = wx.createAnimation({
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation
animation.translateY(200).step()
this.setData({
animationData: animation.export(),
})
setTimeout(function () {
animation.translateY(0).step()
this.setData({
animationData: animation.export(),
showModalStatus: false
})
}.bind(this), 200)
},
})
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}}">
<!--對話框標題-->
<view class="title-view">
<view class="toast-view">
要顯示的內(nèi)容
</view>
</view>
</view>
效果圖:
源碼下載鏈接:http://xiazai.jb51.net/201701/yuanma/toastTestNew(jb51.net).rar
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
- 微信小程序 toast組件詳細介紹
- 微信小程序開發(fā)之toast等彈框提示使用教程
- 微信小程序開發(fā)之實現(xiàn)自定義Toast彈框
- 微信小程序開發(fā)之toast提示插件使用示例
- 微信小程序?qū)崙?zhàn)之自定義toast(6)
- 微信小程序 toast 詳解及實例代碼
- 微信小程序 自定義Toast實例代碼
- 微信小程序自定義toast彈窗效果的實現(xiàn)代碼
- 微信小程序自定義toast實現(xiàn)方法詳解【附demo源碼下載】
- 微信小程序使用component自定義toast彈窗效果
- 微信小程序自定義toast的實現(xiàn)代碼
- 微信小程序自定義toast組件的方法詳解【含動畫】
相關(guān)文章
小程序開發(fā)踩坑:頁面窗口定位(相對于瀏覽器定位)(推薦)
這篇文章主要介紹了小程序開發(fā)頁面窗口定位,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-04-04
JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式
這篇文章主要為大家介紹了JS網(wǎng)頁repaint與reflow?的區(qū)別及優(yōu)化方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-09-09
JavaScript實現(xiàn)隊列結(jié)構(gòu)過程
這篇文章主要介紹了JavaScript實現(xiàn)隊列結(jié)構(gòu)的過程,隊列即Queue,它是受限的線性表,先進先出,受限之處在于它只允許在表的前端進行刪除操作,下面我們一起進入文章學習更加詳細內(nèi)容,需要的朋友也可以參考一下2021-12-12


