语法
画矩形
context.rect(0, 0, 150, 75);
context.setFillStyle('#fff');
context.fill();
等价于:
context.fillRect(0, 0, 150, 75);
画三角形
原理:用两个旋转45度的白色矩形挡住带颜色的矩形,得出带颜色的三角形。[平面几何知识]
{
// 三角形,要挡住正方形上面一点
type: 'image',
y: (150 + 110) / 2,
x: (250 + 25) / 2,
url: this.imgJkTriangle,
style: {
width: 112 / 2,
height: 112 / 2
}
}
字体斜体、加粗
ctx.font = 'italic bold 18px sans-serif';
注:里面每个值缺一不可,且需按顺序填写。
小程序生成二维码API[注意点]
生成的入参path字符,前面不能有"/"
微信小程序source-map解析
1、微信小程序 Source Map 的使用及一键解析(大全)
https://blog.windstone.cc/articles/wechat-mini-program-sourcemap/#%E8%83%8C%E6%99%AF%E4%BB%8B%E7%BB%8D
注:里面有微信小程序 source-map在线解析工具
https://blog.windstone.cc/tools/wechat-mini-program-sourcemap
2、node插件(sourcemap-lookup插件)解析sourcemap问题
https://blog.csdn.net/weixin_43840202/article/details/113663409
注:
上传压缩为true时,sourcemap正常生成!,再通过在线工具查看报错位置
错误码40029
后台请求的appid不对 或是 开发者工具》详情》基本信息设置的appid不对
设置接口超时处理
1、在app.json加入一句
"networkTimeout": {
"request": 10000
}
设置超时时间,单位毫秒
2、请求
wx.request时超时会进入fail方法
fail: function () {
wx.hideLoading();
wx.showModal({
title: '提示',
showCancel: false,
content: '请求超时,请退出重新扫码!',
success: function () {
wx.redirectTo({
url: '../scan/scan'
})
}
})
}
微信分享——分享好友
方法:
onShareAppMessage
按钮:
<button
class="we-btn we-btn--primary"
open-type="share"
>立即邀请</button>
cover-view标签,line-height不生效
微信支付跳客户小程序的传参约定:
动态设置style
- 动态设置高度
setTimeout(function () {
var query = wx.createSelectorQuery();
query.select(‘.nd-btnBox’).boundingClientRect();
query.exec(function (rect) {
if (rect[0] === null) return;
that.setData({
marginBM: rect[0].height + 10
})
});
}, 500)
https://www.cnblogs.com/zjjDaily/p/9566234.html - 动态设置宽高
let query = wx.createSelectorQuery().in(this);
query.select(‘#movableArea’).boundingClientRect((rect) => {
console.log(‘rect’, rect)
let x = rect.width;
let y = rect.height / 2;
this.setData({x,y})
}).exec() // exec 真重要,光调用上面的方法,不调用 exec 是不执行的,自己走过的坑,记录一下子
https://blog.csdn.net/qq_38652871/article/details/106122212
微信开发者工具》详情》postcss
上传代码时样式自动补全
微信小程序的管理台,开发版本会保留每人最新的一份上传的代码。
微信小程序,注册全局监听事件
https://developers.weixin.qq.com/community/develop/article/doc/000ec00656c7f0c3266af0da05b813
微信小程序,注册全局组件
app.json,写usingcomponents
指纹登录:
失败:90009
取消:90008
微信小程序app.json的属性pages
// 主包
"pages": [
"pages/start/start",
"pages/shop/select"
],
// 子包
"subpackages": [
{
"root": "packageStreamMedia",
"name": "packageStreamMedia",
"pages": [
"pages/videoCall/videoCall",
"pages/live-anchor/index",
]
}
]
app.json页面预加载preloadRule
"preloadRule": {
"pages/index": {
"network": "all",
"packages": ["important"]
},
"sub1/index": {
"packages": ["hello", "sub3"]
},
"sub3/index": {
"packages": ["path/to"]
},
"indep/index": {
"packages": ["__APP__"]
}
}