原文:微信小程序把玩(四)应用生命周期

App() 函数用来注册一个小程序,注意必须在 app.js 中注册,且不能注册多个。
使用方式也跟Android中的Application中初始化一些全局信息以供使用。
方法:

应用生命周期代码:

$(function () {
$(‘pre.prettyprint code‘).each(function () {
var lines = $(this).text().split(‘\n‘).length;
var $numbering = $(‘
‘).addClass(‘pre-numbering‘).hide();
$(this).addClass(‘has-numbering‘).parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($(‘
‘).text(i));
};
$numbering.fadeIn(1700);
});
});