当前位置:网站首页>微信小程序常用集合
微信小程序常用集合
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"
]
}
]结束语
未完待续...
边栏推荐
- 【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
- mod_ WSGI + pymssql path SQL server seat
- Database specific interpretation of paradigm
- LeetCode_格雷编码_中等_89.格雷编码
- Interpretation of Dagan paper
- HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
- logstash高速入口
- Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
- [play with Linux] [docker] MySQL installation and configuration
- 121. 买卖股票的最佳时机
猜你喜欢
算法面试经典100题,Android程序员最新职业规划

腾讯T3手把手教你,真的太香了

Interview assault 63: how to remove duplication in MySQL?

(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of

Example of applying fonts to flutter

After solving 2961 user feedback, I made such a change

企业精益管理体系介绍

Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech

Understand yolov1 Part II non maximum suppression (NMS) in prediction stage

在解决了 2961 个用户反馈后,我做出了这样的改变...
随机推荐
Recursive implementation of department tree
LeetCode_格雷编码_中等_89.格雷编码
logstash高速入口
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer
Cesium 两点之间的直线距离
《数字经济全景白皮书》保险数字化篇 重磅发布
如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Information System Project Manager - Chapter VIII project quality management
Monthly report of speech synthesis (TTS) and speech recognition (ASR) papers in June 2022
Analysis of rainwater connection
leetcode先刷_Maximum Subarray
Alibaba data source Druid visual monitoring configuration
Low CPU load and high loadavg processing method
It's enough to read this article to analyze the principle in depth
腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
激进技术派 vs 项目保守派的微服务架构之争
Standardized QCI characteristics
ZABBIX proxy server and ZABBIX SNMP monitoring