当前位置:网站首页>Wechat applet common collection
Wechat applet common collection
2022-07-06 20:05:00 【Infatuated Arvin】
Catalog
Wechat applet gets the size of uploaded pictures
Wechat applet base64 Bit size calculation
Wechat applet gets the size of uploaded pictures
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilesSize = res.tempFiles[0].size; // Get the size of the picture , Company B
const tempFilePaths = res.tempFilePaths;
console.log('size:', tempFilesSize)
if (tempFilesSize <= 2000000) { // Picture is less than or equal to 2M when You can get pictures
// code
} else { // Picture larger than 2M, Pop up a prompt box
wx.showToast({
title: ' Upload image cannot be larger than 2M!', // title
icon: 'none' // Icon none Don't use icons , For details, see the official documents
})
}
},
fail: function (res) {
wx.hideLoading()
}
});
Wechat applet base64 Bit size calculation
/****base64 Bit size calculation **/
getImgSize(str) {
// obtain base64 Picture size , return KB Numbers
var str = base64url.replace('data:image/jpeg;base64,', '');// Here according to their own upload image format for the corresponding modification
var strLength = str.length;
var fileLength = parseInt(strLength - (strLength / 8) * 2);
// From byte to byte KB
var size = "";
size = (fileLength / 1024).toFixed(2);
return parseInt(size);
},
Wechat applet subcontracting
"subPackages": [
{
"root": "A/",
"pages": [
"index/index",
"form/form"
]
},
{
"root": "B/",
"pages": [
"index/index",
"form/form"
]
}
]
Conclusion
To be continued ...
边栏推荐
猜你喜欢
Redisson bug analysis
Node. Js: express + MySQL realizes registration, login and identity authentication
An East SMS login resurrection installation and deployment tutorial
枚举根据参数获取值
PowerPivot——DAX(初识)
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)
信息系统项目管理师---第八章 项目质量管理
腾讯T3大牛手把手教你,大厂内部资料
随机推荐
PowerPivot - DAX (first time)
腾讯T4架构师,android面试基础
PHP与EXCEL PHPExcel
After solving 2961 user feedback, I made such a change
(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
Alibaba data source Druid visual monitoring configuration
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer
mod_ WSGI + pymssql path SQL server seat
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Phoenix Architecture 3 - transaction processing
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
枚举根据参数获取值
精彩编码 【进制转换】
某东短信登录复活 安装部署教程
Tencent T2 Daniel explained in person and doubled his job hopping salary
Information System Project Manager - Chapter VIII project quality management
Test Li hi
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
腾讯安卓开发面试,android开发的基础知识
Node.js: express + MySQL实现注册登录,身份认证