代码拉取完成,页面将自动刷新
import _util from "./Util";
import _fetch from "./Fetch";
import _router from './Router'
let originPage = Page;
let originComponent = Component;
Page = (opt) => {
opt = {
...opt,
_util,
_fetch,
_router
}
return originPage(opt);
}
Component = (opt) => {
let { props = {} } = opt;
let properties = {};
// 优化 properties 传入方式
Object.keys(props).forEach(item => {
properties[item] = {
type: _util.getValueType(props[item]),
value: props[item],
observer: function (newVal, oldVal, changedPath) {
const changeEvent = {
event: item,
newVal, oldVal, changedPath
};
// 传入属性可通过组件内定义的$watch方法统一监听变化
this.$watch && this.$watch(changeEvent);
}
}
});
opt.properties = properties;
// Component函数的options无法传入参数 只能在某个生命周期函数被调用时动态赋值
let originAttached = opt.attached || function () {};
opt.attached = function() {
this._util = _util;
this._fetch = _fetch;
this._router = _router;
return originAttached.apply(this);
}
return originComponent(opt)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。