图片组件WImage--自带缩放、拖拽、旋转

最近因需求,需要图片实现缩放,拖拽等功能,就写了这个组件,用起来方便多了,现在把这个组件整理一下,大家有需要的话可以试试。

先看图,然后再对这个组件的使用进行详细解释:

这个组件可以使用鼠标操作,也可以点击进行操作,不过旋转图片只能使用按钮操作。

一、安装组件:
// yarn 安装
yarn add @travel_wsy/w_image

// npm 安装
npm install @travel_wsy/w_image -S
二、组件参数与方法说明:
  1、参数:
参数名称参数类型参数介绍默认值
imgWidthstring图片宽度300px
imgHeightstring图片高度300px
srcstring图片地址
2、方法:
回调方法返回参数参数介绍返回默认值
ImageChange

{

scale:number,

left:number,

top:number

}

scale:图片缩放比例

left:图片左偏移

top:图片上偏移

scale:0,

left:0,

top:0

内置方法参数参数说明默认值
handleActiveBtns

{

scaleAdd:false,

scaleMinus:false,

rotateLeft:false,

rotateRight:false
}

scaleAdd:是否放大图片,

scaleMinus:是否缩小图片,

rotateLeft:是否逆时针旋转,

rotateRight:是否顺时针旋转

scaleAdd:false,

scaleMinus:false,

rotateLeft:false,

rotateRight:false

3、引入:
import { WImage } from '@travel_wsy/w_image'
4、具体使用:
<WImage ref="wimageRef" imgWidth="600px" imgHeight="600px" src="" ></WImage>
<el-button type="primary" @click="handleSet(1)">放大</el-button>
<el-button type="primary" @click="handleSet(2)">缩小</el-button>
<el-button type="primary" @click="handleSet(3)">顺时针旋转</el-button>
<el-button type="primary" @click="handleSet(4)">逆时针旋转</el-button>
    handleSet(type){
      let activeObj = {}
      if(type == 1){
        activeObj['scaleAdd'] = true
      }else if(type == 2){
        activeObj['scaleMinus'] = true
      }else if(type == 3){
        activeObj['rotateRight'] = true
      }else if(type == 4){
        activeObj['rotateLeft'] = true
      }
      this.$refs.wimageRef.handleActiveBtns(activeObj)
    }
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

travel_wsy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值