原文:微信小程序把玩(二十四)toast组件
toast消息提示框,可用在提示一些信息,比如清楚缓存给用户一个友好的提示!或操作一些请求不想让用户有什么操作,toast也可以做到因为toast显示时其他操作是无效的
主要属性:
wxml
<!--点击button触发toast--> <button type="primary" bindtap="listenerButton">点击显示toast</button> <!--toast消息框显示3秒,并绑定事件--> <toast hidden="{{hiddenToast}}" duration="3000" bindchange="toastHidden" >OK!</toast>
js
Page({
data:{
// text:"这是一个页面"
hiddenToast: true
},
/** * 监听button点击事件 */
listenerButton: function() {
this.setData({
hiddenToast: !this.data.hiddenToast
})
},
/** * toast显示时间到时处理业务 */
toastHidden:function(){
this.setData({
hiddenToast: true
})
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
onReady:function(){
// 页面渲染完成
},
onShow:function(){
// 页面显示
},
onHide:function(){
// 页面隐藏
},
onUnload:function(){
// 页面关闭
}
})
$(function () {
$(‘pre.prettyprint code‘).each(function () {
var lines = $(this).text().split(‘\n‘).length;
var $numbering = $(‘
$(this).addClass(‘has-numbering‘).parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($(‘ ‘).text(i));
};
$numbering.fadeIn(1700);
});
});