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

小程序

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

相关推荐
头发还在的女程序员14 小时前
基于 Spring Boot + Vue 3 + uni-app 的灵活用工系统:四端架构与业务流程设计
vue.js·spring boot·uni-app·灵活用工·灵工系统
wafrdggh1 天前
2026电商快递批量查询怎么用?固乔助手模板设置评测
大数据·数据库·小程序
wafrdggh2 天前
2026 商城小程序平台哪个价格合理?把跨境附加成本这个坑算透
大数据·小程序
Dumbness2 天前
订阅消息弹窗必须在用户点击里调:联调实验室里 timing 和 Mock 支付通知踩的坑
javascript·uni-app
码间留白4 天前
uni-app 鸿蒙离线打包:一个改动从源码到真机要穿过几条链
uni-app·鸿蒙·deveco·离线打包·uts插件
恩创软件开发4 天前
自助KTV系统管理员续单功能
经验分享·小程序
多客:duokelijie4 天前
代练订单系统选型思路:跨品类游戏接入、订单分层管理、自动结算逻辑拆解!
数据库·mysql·微信小程序·前端框架·uni-app·php·持续部署
码间留白4 天前
鸿蒙端对接 BLE 血压计:从一次握手到读数入库(二)设备篇
物联网·uni-app·鸿蒙·蓝牙ble·血压计
AI源码5 天前
在线考试小程序
小程序·notepad++
华玥作者5 天前
Vue 3 + TypeScript + uni-app 组件库推荐:hy-app(华玥组件库)
vue.js·typescript·uni-app