当前位置:网站首页>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 ...
边栏推荐
- 腾讯云数据库公有云市场稳居TOP 2!
- 精彩编码 【进制转换】
- AddressSanitizer 技术初体验
- HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
- 腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
- 企业精益管理体系介绍
- Monthly report of speech synthesis (TTS) and speech recognition (ASR) papers in June 2022
- 《数字经济全景白皮书》保险数字化篇 重磅发布
- 腾讯T3大牛手把手教你,大厂内部资料
- Introduction to enterprise lean management system
猜你喜欢
深度剖析原理,看完这一篇就够了
腾讯架构师首发,2022Android面试笔试总结
深入浅出,面试突击版
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
【云原生与5G】微服务加持5G核心网
5. Nano - Net in wireless body: Top 10 "is it possible?" Questions
[play with Linux] [docker] MySQL installation and configuration
腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
随机推荐
Color is converted to tristimulus value (r/g/b) (dry stock)
Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
Database specific interpretation of paradigm
Monthly report of speech synthesis (TTS) and speech recognition (ASR) papers in June 2022
AsyncHandler
PHP and excel phpexcel
Cesium Click to draw a circle (dynamically draw a circle)
Problems encountered in using RT thread component fish
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
POJ1149 PIGS 【最大流量】
logstash高速入口
Period compression filter
HDU 1026 Ignatius and the Princess I 迷宫范围内的搜索剪枝问题
夏志刚介绍
【计网】第三章 数据链路层(3)信道划分介质访问控制
JVM_常见【面试题】
What happened to the kernel after malloc() was transferred? Attached malloc () and free () implementation source
Qinglong panel white screen one key repair
Example of applying fonts to flutter