【总结】uniapp以及wx小程序 相关写法集合

一、css

二、方法

uniApp

1、动态修改头部标题

复制代码
uni.setNavigationBarTitle({
	title: this.dynamicTitle,
	success: () => {
		console.log('修改标题成功')
	},
	fail: () => {
		console.log('修改标题失败')
	},
	complete: () => {
		console.log('修改标题结束')
	}
})

2、预览图片单张/多张(拖动缩放),识别https

复制代码
uni.previewImage({
	// 需要预览的图片链接列表
	urls: [res.tempFilePath],
	// 为当前显示图片的链接/索引值
	current: res.tempFilePath,
	// 图片指示器样式
	indicator:'default',
	// 是否可循环预览
	loop:false
});

3、获取图片的详细信息

复制代码
uni.getImageInfo({
	src: '/static/bg_icon.png', // 图片地址
	success(res) {
       console.log(res.path)
    }
})

4、将画布内容生成临时文件路径

复制代码
uni.canvasToTempFilePath({
	canvasId: 'canvas1',
	success: (res) => {
		console.log(res.tempFilePath)
	},
	fail: (res) => {
       // 失败
	}
})

5、文件下载

复制代码
uni.downloadFile({
	url: 'https://open-laser.oss-cn-shanghai.aliyuncs.com/ab965f82ebc64f92bd2f3d53c595bfb0.jpg',
	success: (res)=>{
		console.log(res.tempFilePath)
	}
})

6、文件上传

复制代码
uni.uploadFile({
	url: 'https://open-laser.oss-cn-shanghai.aliyuncs.com/ab965f82ebc64f92bd2f3d53c595bfb0.jpg',
	success: (res)=>{
		console.log(res.tempFilePath)
	}
})

7、保存图片

复制代码
uni.saveImageToPhotosAlbum({
	filePath: '../static/icon.png',
	success(res) {
		uni.showToast({
			icon: 'success',
			mask: true,
			title: '保存成功',
		});
	},
	fail(res) {
		console.log(res.errMsg)
	}
})

8、模块的拖动双指缩放

复制代码
<template> 
  <movable-area v-if="person.isShowExam" @click.stop="person.isShowExam=!person.isShowExam">
	<movable-view  direction="all" @scale="onScale" scale scale-min="0.5" scale-max="4" >
     <!-- 内容  -->
	</movable-view>
  </movable-area>
  <view @click.stop="person.isShowExam=true">预览</view>
</template>

<script setup>
import { reactive } from 'vue'
let person=reactive({
	isShowExam:false
})
</script>

<style lang="scss" scoped>
movable-area {
	position: fixed;
	top: 0;
	left: 0;
	width: 375px;
	height: 100vh;
	background: #000;
	overflow: hidden;
	z-index: 9999;
	movable-view {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
}
</style>

小程序

希望我的愚见能够帮助你哦~,若有不足之处,还望指出,你们有更好的解决方法,欢迎大家在评论区下方留言支持,大家一起相互学习参考呀~

相关推荐
weixin_493503676 小时前
商会小程序附件上传:分片上传 + OSS 直传完整实现(Vue3 + 阿里云 OSS 实战)
阿里云·小程序·云计算
优度网8 小时前
微信小程序主体变更公证书线上办理流程与业务交接风险规避方法浅析(2026)
小程序
m0_587383009 小时前
外卖CPS系统开发实战:从架构设计到运营落地全指南
java·spring·小程序·架构·需求分析
梦曦i11 小时前
uni-router v0.2.0重磅发布:全链路拦截+重复导航优化
前端·uni-app
EatFan11 小时前
【实战经验】uni-app使用 SSE 踩坑,EventSource不支持怎么办?
android·后端·ios·uni-app
T011561816 小时前
全栈项目实战手记|艺培场馆课时预约小程序 PC 管理端 Demo 完整开发成果展示
小程序
凡泰AI16 小时前
如何为政务 APP 搭建开放平台,实现多部门、第三方供应商标准化入驻与统一管理
android·大数据·小程序·uni-app·app·政务
FX1317887KP_17 小时前
AI陪练正在重塑KET PET FCE口语备考,传统外教课还有必要吗?
人工智能·小程序·ket口语·pet口语·fce备考·剑桥英语
lhldsg17 小时前
从零构建智慧场馆解决方案小程序:开发全流程实战
java·前端·小程序
vx-Biye_Design1 天前
SSM伴侣动物伴护星小程序06330-计算机课程设计、毕业设计
spring boot·后端·elasticsearch·小程序·架构·课程设计·idea