vue图片裁剪 vue-cropper使用

vue图片裁剪插件vue-cropper

最近有图片裁剪的需求,做完后感觉vue-cropper这个插件使用比较方便、顺手,在此分享给大家。

vue-cropper插件使用

地址: https://github.com/xyxiao001/vue-cropper
使用:

# npm 安装
npm install vue-cropper

# yarn 安装
yarn add vue-cropper

# main.js里面使用 挂载全局
import VueCropper from 'vue-cropper'
Vue.use(VueCropper)

# 组件内使用
import {
    VueCropper } from 'vue-cropper'
components: {
   
	VueCropper
}

组件样式

在这里插入图片描述
在这里插入图片描述

组件封装

npm安装好vue-cropper,封装组件Qd-cropper,在组件中直接引用vue-cropper即可

<template>
  <div v-if="modal">
    <Modal v-model="modal" :loading="true" :width="1000" :mask-closable="false" ref="tablemodal">
      <p slot="header" style="text-align:center">
        <span>图片裁剪</span>
      </p>
      <div class="cropper_content">
        <div class="cropper_box">
          <div class="cropper_styl">
            <vue-cropper
              ref="cropper"
              :img="option.img"
              :outputSize="option.outputSize"
              :outputType="option.outputType"
              :info="option.info"
              :canScale="option.canScale"
              :autoCrop="option.autoCrop"
              :autoCropWidth="option.autoCropWidth"
              :autoCropHeight="option.autoCropHeight"
              :fixed="option.fixed"
              :fixedNumber="option.fixedNumber"
              :full="option.full"
              :fixedBox="option.fixedBox"
              :canMove="option.canMove"
              :canMoveBox="option.canMoveBox"
              :original="option.original"
              :centerBox="option.centerBox"
              :height="option.height"
              :infoTrue="option.infoTrue"
              :maxImgSize="option.maxImgSize"
              :enlarge="option.enlarge"
              :mode="option.mode"
              @realTime="realTime"
              @imgLoad="imgLoad"
            ></vue-cropper>
          </div>
          <div class="scope_btn">
            <label class="up_btn" for="uploads">上传图片</label>
            <input
              type="file"
              id="uploads"
              style="position: absolute; clip: rect(0 0 0 0)"
              accept="image/png, image/jpeg, image/gif, image/jpg&#
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值