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


