用phpmysql做网站,建设网站的企业,聊城房产网,焦作专业网站建设费用wechat-common-sdk ? 场景#xff1a;目前工作中的项目需要包含并使用另一个项目。 也许是第三方库#xff0c;或者你独立开发的#xff0c;用于多个父项目的库。 现在问题来了#xff1a;你想要把它们当做两个独立的项目#xff0c;同时又想在一个项目中使用另一个。 我… wechat-common-sdk ? 场景目前工作中的项目需要包含并使用另一个项目。 也许是第三方库或者你独立开发的用于多个父项目的库。 现在问题来了你想要把它们当做两个独立的项目同时又想在一个项目中使用另一个。 我们举一个例子。 假设你正在开发一个网站然后创建了 Atom 订阅。 你决定使用一个库而不是写自己的 Atom 生成代码。 你可能不得不通过 CPAN 安装或 Ruby gem 来包含共享库中的代码或者将源代码直接拷贝到自己的项目中。 如果将这个库包含进来那么无论用何种方式都很难定制它部署则更加困难因为你必须确保每一个客户端都包含该库。 如果将代码复制到自己的项目中那么你做的任何自定义修改都会使合并上游的改动变得困难。 Git 通过子模块来解决这个问题。 子模块允许你将一个 Git 仓库作为另一个 Git 仓库的子目录。 它能让你将另一个仓库克隆到自己的项目中同时还保持提交的独立。 ##wechat-common-sdk有哪些功能 Interface 小程序公用接口类此接口需和后台api配合使用HttpUtil 小程序http请求类 1.get 请求2.post 请求CanvasUtil 小程序 canvas工具类 1.canvas 文本换行计算2.图片裁剪画圆3.绘制圆角矩形自动统一授权入口 默认开启如果用户未授权则跳入公用授权页面使用方法 进入项目根路径 执行git submodule add github.com/richard1015…更新已存在 submodule 子模块时 需执行 否则项目中wechat-common-sdk 文件夹内容为空 1.git submodule init2.git submodule update3.app.json 中加入 统一授权路径页面 wechat-common-sdk/pages/auth //app.js
import common from ./wechat-common-sdk/common.js;
var util require(./utils/util.js);
App({commonSdk: {},onLaunch: function() {var self thisconsole.log(App Launch)self.util util;self.commonSdk common.init({// host:http://192.168.1.128:18888/,source: 7, //7.汇率计算器redirect: /pages/index/index//授权成功回调地址});},onShow: function() {console.log(App Show)},onHide: function() {console.log(App Hide)}
}) 复制代码 // pages/addCurrency/addCurrency.js
let {commonSdk,util
} getApp();
Page({/*** 生命周期函数--监听页面加载*/onLoad: function(options) {var self this;//获取币种接口commonSdk.HttpUtil.post(exchange/currency, {openId: commonSdk.openid,needRmb: true}).then((res) {if (res.State 0) {console.log(res)let exist [],array [];res.Value.forEach(item {if (item.isExist 1) {exist.push(item)} else {array.push(item)}})self.setData({exist,array,oldArray: array});}});}
})
复制代码 转载于:https://www.cnblogs.com/richard1015/p/9924533.html