架构思维
最近搞微信小程序和vue前端想尽量实现代码的复用性
于是有了想法
基于小程序前端和vue和其他juery 等前端整合,尽量实现代码的复用性
前端架构分成: 分为技术组件和业务组件
技术组件只管技术的部分
业务组件和具体的业务有关
js中具体的业务组件调用技术组件同一个方法
比如 基于 axios 和 promises 实现的一个调用接口 小程序和vue的写法一样,但是弹窗提醒不同 ,但是我想代码一样这样搞
调用这个方法comBase.comWebFraIntegrate_fun_showMsg('加载完成');
this.$utHttp({
url: this.$utHttp.adornUrl("secmod/oper/thirdexa/thirdexaId"),
method: "put",
params: this.$utHttp.adornParams(row)
}).then(({ data }) => {
if (data && data.rsucc) {
}else {
}
this.vdDa_sear_form.form_keyAll_pre=this.vdDa_sear_form.form_keyAll;
this.vdDa_table_loading = false;
comBase.comWebFraIntegrate_fun_showMsg('','加载完成');
});
然后引入小程序的技术组件将业务组件中的方法映射到小程序的弹窗中
//显示消息后关闭
comBase.comWebFraIntegrate_fun_showMsg_wxMinApp = function(webFrameI_showTitle, webFrameI_showMsg) {
if (webFrameI_showMsg == null) webFrameI_showMsg = "";
wx.showToast({
title: webFrameI_showTitle,
content: webFrameI_showMsg,
duration: 10000
})
setTimeout(function() {
wx.hideToast()
}, 2000)
}
comBase.comWebFraIntegrate_fun_showMsg=comBase.comWebFraIntegrate_fun_showMsg_wxMinApp ;
相同的如果是vue你映射到vue就好了