当前位置:网站首页>微信小程序常用集合
微信小程序常用集合
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"
]
}
]
结束语
未完待续...
边栏推荐
- From spark csc. csr_ Matrix generate adjacency matrix
- Cesium 点击绘制圆形(动态绘制圆形)
- mod_ WSGI + pymssql path SQL server seat
- 350. Intersection of two arrays II
- 腾讯T4架构师,android面试基础
- RT-Thread 组件 FinSH 使用时遇到的问题
- Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
- Application of clock wheel in RPC
- 【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
- MySQL information schema learning (I) -- general table
猜你喜欢
A5000 vGPU显示模式切换
Learning and Exploration - Seamless rotation map
Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?
腾讯T3手把手教你,真的太香了
Li Kou 101: symmetric binary tree
Introduction to enterprise lean management system
[play with Linux] [docker] MySQL installation and configuration
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
在解决了 2961 个用户反馈后,我做出了这样的改变...
算法面试经典100题,Android程序员最新职业规划
随机推荐
121. The best time to buy and sell stocks
2022年6月语音合成(TTS)和语音识别(ASR)论文月报
从sparse.csc.csr_matrix生成邻接矩阵
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
MySQL information Schema Learning (i) - - General table
RT-Thread 组件 FinSH 使用时遇到的问题
Interview assault 63: how to remove duplication in MySQL?
小微企业难做账?智能代账小工具快用起来
精彩编码 【进制转换】
技术分享 | 抓包分析 TCP 协议
Leetcode 30. Concatenate substrings of all words
1805. Number of different integers in the string
Application of clock wheel in RPC
Synchronization of data create trigger synchronization table for each site
Poj1149 pigs [maximum flow]
系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
js实现力扣71题简化路径
MySQL must know and learn
Leetcode brush first_ Maximum Subarray
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance