当前位置:网站首页>微信小程序常用集合
微信小程序常用集合
2022-07-06 12:07:00 【痴心阿文】
目录
微信小程序获取上传图片大小
wx.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilesSize = res.tempFiles[0].size; //获取图片的大小,单位B
const tempFilePaths = res.tempFilePaths;
console.log('size:', tempFilesSize)
if (tempFilesSize <= 2000000) { //图片小于或者等于2M时 可以执行获取图片
// code
} else { //图片大于2M,弹出一个提示框
wx.showToast({
title: '上传图片不能大于2M!', //标题
icon: 'none' //图标 none不使用图标,详情看官方文档
})
}
},
fail: function (res) {
wx.hideLoading()
}
});
微信小程序base64位大小计算
/****base64位大小计算**/
getImgSize(str) {
//获取base64图片大小,返回KB数字
var str = base64url.replace('data:image/jpeg;base64,', '');//这里根据自己上传图片的格式进行相应修改
var strLength = str.length;
var fileLength = parseInt(strLength - (strLength / 8) * 2);
// 由字节转换为KB
var size = "";
size = (fileLength / 1024).toFixed(2);
return parseInt(size);
},
微信小程序小程序分包
"subPackages": [
{
"root": "A/",
"pages": [
"index/index",
"form/form"
]
},
{
"root": "B/",
"pages": [
"index/index",
"form/form"
]
}
]
结束语
未完待续...
边栏推荐
- Interview assault 63: how to remove duplication in MySQL?
- Microservice architecture debate between radical technologists vs Project conservatives
- Application of clock wheel in RPC
- 【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
- [translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
- 350. Intersection of two arrays II
- 腾讯架构师首发,2022Android面试笔试总结
- Mysql Information Schema 学习(二)--Innodb表
- 转让malloc()该功能后,发生了什么事内核?附malloc()和free()实现源
- 蓝桥杯 微生物增殖 C语言
猜你喜欢
VMware virtual machine cannot open the kernel device "\.\global\vmx86"
How to customize animation avatars? These six free online cartoon avatar generators are exciting at a glance!
学习打卡web
【计算情与思】扫地僧、打字员、信息恐慌与奥本海默
MySQL information Schema Learning (i) - - General table
Using clip path to draw irregular graphics
MySQL information schema learning (I) -- general table
beegfs高可用模式探讨
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
新一代垃圾回收器—ZGC
随机推荐
MySQL must know and learn
Spark foundation -scala
POJ1149 PIGS 【最大流量】
信息系统项目管理师---第八章 项目质量管理
Color is converted to tristimulus value (r/g/b) (dry stock)
Learning and Exploration - function anti shake
理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
Understand yolov1 Part II non maximum suppression (NMS) in prediction stage
深度剖析原理,看完这一篇就够了
青龙面板白屏一键修复
LeetCode_双指针_中等_61. 旋转链表
Microservice architecture debate between radical technologists vs Project conservatives
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
范式的数据库具体解释
Finally, there is no need to change a line of code! Shardingsphere native driver comes out
Mysql Information Schema 學習(一)--通用錶
Tensorflow2.0 self defined training method to solve function coefficients
Example of applying fonts to flutter
系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I