当前位置:网站首页>微信小程序常用集合
微信小程序常用集合
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"
]
}
]结束语
未完待续...
边栏推荐
- HDU 1026 Ignatius and the Princess I 迷宫范围内的搜索剪枝问题
- 1805. 字符串中不同整数的数目
- [translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
- PHP and excel phpexcel
- 激进技术派 vs 项目保守派的微服务架构之争
- 《数字经济全景白皮书》保险数字化篇 重磅发布
- It's enough to read this article to analyze the principle in depth
- POJ1149 PIGS 【最大流量】
- ZABBIX proxy server and ZABBIX SNMP monitoring
- In depth analysis, Android interview real problem analysis is popular all over the network
猜你喜欢

Transformer model (pytorch code explanation)

How to access localhost:8000 by mobile phone

In simple terms, interview surprise Edition

Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference

手把手教你学会js的原型与原型链,猴子都能看懂的教程
腾讯T2大牛亲自讲解,跳槽薪资翻倍

理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
![[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer](/img/8c/afb90128e7a523bbee4c6c4166363f.png)
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer

Interpretation of Dagan paper

语音识别(ASR)论文优选:全球最大的中英混合开源数据TALCS: An Open-Source Mandarin-English Code-Switching Corpus and a Speech
随机推荐
Configuration and simple usage of the EXE backdoor generation tool quasar
Wonderful coding [hexadecimal conversion]
MySQL information schema learning (I) -- general table
MySQL information schema learning (II) -- InnoDB table
HDU 1026 search pruning problem within the labyrinth of Ignatius and the prince I
Period compression filter
Test Li hi
Dom 操作
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
Using clip path to draw irregular graphics
腾讯Android面试必问,10年Android开发经验
Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
Blue Bridge Cup microbial proliferation C language
深度剖析原理,看完这一篇就够了
腾讯T3大牛手把手教你,大厂内部资料
手把手教你学会js的原型与原型链,猴子都能看懂的教程
【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
Method keywords deprecated, externalprocname, final, forcegenerate
腾讯架构师首发,2022Android面试笔试总结