【总结】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>

小程序

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

相关推荐
CHB7 小时前
uni-app x 蒸汽模式 性能测试基准报告 Benchmark【Android版】
android·ios·uni-app
show43316 小时前
多格式导出怎么做?2026免费小程序TXT/SRT实践
开发语言·小程序·c#
AI砖家17 小时前
AI编程—微信小程序开发规范
微信小程序·小程序·notepad++·ai编程
show4331 天前
2026小程序端视频转文字技术对比:识别引擎精度实测
小程序·音视频
sam-zy1 天前
微信小程序+ESP8266+Arduino 开发智能插座,有本地OTA功能
微信小程序·小程序
A24207349302 天前
微信小程序开发:常用基础语法与指令详解
微信小程序·小程序·notepad++
黄华SJ520it2 天前
青蓝送水类型社交裂变小程序系统技术拆解
小程序·系统开发
weikecms2 天前
星巴克API接口,星巴克点餐接口开发
大数据·小程序
游戏开发爱好者82 天前
系统状态:专为iPhone和iPad设计的实时系统性能监控工具全面介绍
android·ios·小程序·uni-app·iphone·webview·ipad
2501_915909062 天前
全面解析iOS应用上架到App Store的完整流程与关键注意事项
android·macos·ios·小程序·uni-app·cocoa·iphone