const defaultSet={
data:{
theme:theme
},
// 设置加载中的状态 tool
//setLoading(loading, state) {
//const key = `loading.${loading}`
// this.setData({
// [key]: state ? true : false
// })
//}
}
const that = this
let originalPage = Page
Page = function(obj) {
return originalPage(util.deepMerge(defaultSet,obj))
}
let originalComponent = Component
Component = function(obj) {
return originalComponent(util.deepMerge(defaultSet,obj))
}
像设置Page一样设置没做到,不过通过Component生命周期为 Component 添加了 一些公共参数
defaultData = {ab:123}
if(!obj.lifetimes){
obj.lifetimes = {};
}
if(!obj.lifetimes.created){
obj.lifetimes.created = function(){};
}
let lifeCreated = obj.lifetimes.created;
obj.lifetimes.created = function(){
Object.assign(this,defaultData);
lifeCreated.call(this);
}
是不是你把全局的Component重新赋值导致的 换个名看看