当前位置:网站首页>微信小程序常用集合
微信小程序常用集合
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"
]
}
]结束语
未完待续...
边栏推荐
- Using clip path to draw irregular graphics
- HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
- It's enough to read this article to analyze the principle in depth
- Method keywords deprecated, externalprocname, final, forcegenerate
- 句号压缩过滤器
- 信息系统项目管理师---第八章 项目质量管理
- 深入浅出,面试突击版
- 理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
- 青龙面板白屏一键修复
- Test Li hi
猜你喜欢
In depth analysis, Android interview real problem analysis is popular all over the network

《数字经济全景白皮书》保险数字化篇 重磅发布

How to do smoke test

How to access localhost:8000 by mobile phone

系统性详解Redis操作Hash类型数据(带源码分析及测试结果)

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

MySQL information schema learning (I) -- general table

Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe

It's enough to read this article to analyze the principle in depth

Microservice architecture debate between radical technologists vs Project conservatives
随机推荐
A5000 vGPU显示模式切换
腾讯架构师首发,2022Android面试笔试总结
[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
Tensorflow2.0 自定义训练的方式求解函数系数
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
What happened to the kernel after malloc() was transferred? Attached malloc () and free () implementation source
系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
PHP与EXCEL PHPExcel
Mysql Information Schema 学习(二)--Innodb表
Standardized QCI characteristics
Transformer model (pytorch code explanation)
转让malloc()该功能后,发生了什么事内核?附malloc()和free()实现源
Yyds dry goods inventory leetcode question set 751 - 760
Social recruitment interview experience, 2022 latest Android high-frequency selected interview questions sharing
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Application of clock wheel in RPC
Dom 操作
Lick the dog until the last one has nothing (simple DP)
精彩编码 【进制转换】