当前位置:网站首页>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 ...
边栏推荐
- leetcode先刷_Maximum Subarray
- mod_wsgi + pymssql通路SQL Server座
- 深入浅出,面试突击版
- 爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
- Cesium 两点之间的直线距离
- Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
- Color is converted to tristimulus value (r/g/b) (dry stock)
- The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
- rt-thread i2c 使用教程
- AsyncHandler
猜你喜欢
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
Li Kou 101: symmetric binary tree
PowerPivot - DAX (first time)
Tencent Android interview must ask, 10 years of Android development experience
手把手教你学会js的原型与原型链,猴子都能看懂的教程
腾讯T2大牛亲自讲解,跳槽薪资翻倍
Interpretation of Dagan paper
redisson bug分析
企业精益管理体系介绍
After solving 2961 user feedback, I made such a change
随机推荐
句号压缩过滤器
Cf960g - bandit Blues (type I Stirling number +ogf)
【Yann LeCun点赞B站UP主使用Minecraft制作的红石神经网络】
Standardized QCI characteristics
深入浅出,面试突击版
Hudi vs Delta vs Iceberg
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)
微信小程序常用集合
Period compression filter
Poj3617 best cow line
新一代垃圾回收器—ZGC
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
Linear distance between two points of cesium
Example of shutter text component
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
Learning and Exploration - function anti shake
数据的同步为每个站点创建触发器同步表
Phoenix Architecture 2 - accessing remote services
From spark csc. csr_ Matrix generate adjacency matrix
爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解