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

小程序

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

相关推荐
军军君016 小时前
基于Springboot+UniApp+Ai实现模拟面试小工具四:后端项目基础框架搭建下
spring boot·spring·面试·elementui·typescript·uni-app·mybatis
Byte_Me8 小时前
IoT 小程序:如何破解设备互联的碎片化困局?
物联网·小程序·iot
小徐_233311 小时前
uni-app 弹窗总被父元素“绑架”?3招破局,H5/小程序/APP一招通杀!
前端·微信小程序·uni-app
Java陈序员17 小时前
又一款基于 SpringBoot + Vue 实现的开源新零售商城系统!
vue.js·spring boot·uni-app
2501_915921431 天前
没有Mac如何完成iOS 上架:iOS App 上架App Store流程
android·ios·小程序·https·uni-app·iphone·webview
说私域1 天前
基于定制开发开源AI智能名片与S2B2C商城小程序的旅游日志创新应用研究
人工智能·小程序·旅游
脑袋大大的1 天前
钉钉小程序开发环境配置与前端开发指南
小程序·钉钉·企业应用开发
玩代码的菜鸟1 天前
uniapp类似抖音视频滑动
uni-app
2301_805962931 天前
微信小程序控制空调之接收MQTT消息
微信小程序·小程序·esp32
The_era_achievs_hero1 天前
微信小程序121~130
微信小程序·小程序