uniapp怎么实现图片同比率压缩和放大?
网友回复
可以通过canvas和uni.canvasToTempFilePath的destWidth与destHeight实现图片放大或缩小输出,示例代码如下:
<template> <view class="container"> <canvas canvas-id="myCanvas" id="myCanvas" class="canvas"></canvas> <button type="primary" @click="exportImage">导出大图</button> </view> </template> <script> export default { data() { return { canvasWidth: 300, // Canvas 宽度 canvasHeight: 300, // Canvas 高度 scale: 3 // 放大倍数 }; }, methods: { drawCanvas() { const ctx = uni.createCanvasContext('myCanva...
点击查看剩余70%