代码拉取完成,页面将自动刷新
import _lodash from 'lodash';
import _SAX from 'fkp-sax';
/* pages类及pages生周期 */
function pages(opts){
var page = _SAX.get('_CURENT_PAGE')
if (page){
var intent = _SAX.get(page)
this.intent = intent;
}
else {
this.intent = false;
}
var _this = this;
var _dft = [];
var defaults = {
init: function(){},
// goback: function(){},
ready: function(){},
main: function(){}
// end: function(){}
}
_dft = Object.keys(defaults)
if ( _lodash.isObject(opts) ){
var defaults = _lodash.extend({}, defaults, opts)
}
var dft = defaults;
var funs = Object.keys(dft)
funs.map(function(item, i){
_this[item] = dft[item];
})
function run(){
var _this = this;
funs.map(function(item, i){
if (typeof dft[item] === 'function'){
if (_lodash.indexOf(_dft, item)>-1)
dft[item].call(_this, _this, _this.intent)
}
})
}
_this.next = function(stat,data){
if (stat){
if (!_this.innerData){
_this.innerData = data;
}
else{
var tmp = _lodash.extend({}, _this.innerData, data)
_this.innerData = tmp;
}
run.call(_this)
}
}
if (_lodash.indexOf(funs, 'boot')>-1){
var stat = dft['boot'].call(_this, _this)
if (stat)
run.call(_this);
}
else
run.call(_this);
return this;
}
pages.new = function(opts){
return new pages(opts)
}
export default pages
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。