Commit 8a8c0297 by 张立顺

配置图片全局路径 IMG_URL

1 parent 7051fa06
module.exports = {
}
\ No newline at end of file
module.exports = {}
import { IMG_URL } from '~/utils/constantData'
/**
* 执行路由前的准备工作
*/
/**处理前置钩子逻辑 */
const routerBefore = (next) => {
const routerBefore = next => {
// console.log("处理前置钩子逻辑");
// 配置图片全局路径
let page = wx.$router.getPageInstance()
page && (page.data.IMG_URL = IMG_URL)
next();
};
next()
}
/**处理后置钩子逻辑 */
const routerAfter = (next) => {
const routerAfter = next => {
// console.log("处理后置钩子逻辑");
next();
};
next()
}
// 重写Page方法
const OldPage = Page;
const OldPage = Page
Page = function (options) {
const oldShow = options.onShow;
const oldHide = options.onHide;
const oldShow = options.onShow
const oldHide = options.onHide
options.onShow = function () {
routerBefore(() => {
oldShow.apply(this, arguments);
});
};
oldShow.apply(this, arguments)
})
}
options.onHide = function () {
routerAfter(() => {
oldHide.apply(this, arguments);
});
};
OldPage(options);
};
oldHide.apply(this, arguments)
})
}
OldPage(options)
}
export default routerBefore;
export default routerBefore
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!