下载

VueCroppie

VueCroppie是一个Vue 2包装Croppie一个美丽的照片裁剪工具的Javascript由foliotek。
安装
NPM
安装vue-croppie—保存
CDN
https://unpkg.com/vue-croppie/dist/vue-croppie.js
使用

import Vue from 'vue';
import VueCroppie from 'vue-croppie'; Vue.use(VueCroppie);

& lt;脚本src = " https://unpkg.com/vue-croppie/dist/vue-croppie.js "比; & lt; body> … & lt; / body> & lt; script> Vue.use (VueCroppie.default); const vm = new Vue({…}); & lt; / script> 样本 下面的示例将生成此内容。

<template>
<div>
<!-- Note that 'ref' is important here (value can be anything). read the description about `ref` below. -->
<vue-croppie
ref=croppieRef
:enableOrientation="true"
@result="result"
@update="update">
</vue-croppie> <!-- the result -->
<img v-bind:src="cropped"> <button @click="bind()">Bind</button>
<!-- Rotate angle is Number -->
<button @click="rotate(-90)">Rotate Left</button>
<button @click="rotate(90)">Rotate Right</button>
<button @click="crop()">Crop Via Callback</button>
<button @click="cropViaEvent()">Crop Via Event</button>
</div>
</template> <script>
export default {
mounted() {
// Upon mounting of the component, we accessed the .bind({...})
// function to put an initial image on the canvas.
this.$refs.croppieRef.bind({
url: 'http://i.imgur.com/Fq2DMeH.jpg',
})
},
data() {
return {
cropped: null,
images: [
'http://i.imgur.com/fHNtPXX.jpg',
'http://i.imgur.com/ecMUngU.jpg',
'http://i.imgur.com/7oO6zrh.jpg',
'http://i.imgur.com/miVkBH2.jpg'
]
}
},
methods: {
bind() {
// Randomize cat photos, nothing special here.
let url = this.images[Math.floor(Math.random() * 4)] // Just like what we did with .bind({...}) on
// the mounted() function above.
this.$refs.croppieRef.bind({
url: url,
});
},
// CALBACK USAGE
crop() {
// Here we are getting the result via callback function
// and set the result to this.cropped which is being
// used to display the result above.
let options = {
format: 'jpeg',
circle: true
}
this.$refs.croppieRef.result(options, (output) => {
this.cropped = output;
});
},
// EVENT USAGE
cropViaEvent() {
this.$refs.croppieRef.result(options);
},
result(output) {
this.cropped = output;
},
update(val) {
console.log(val);
},
rotate(rotationAngle) {
// Rotates the image
this.$refs.croppieRef.rotate(rotationAngle);
}
}
}
</script>

利用期权 所有Croppie选项被转换成道具,以便能够在vue-croppie组件中使用它们。 使用 & lt; vue-croppie ref = croppieRef : enableOrientation = " true " : mouseWheelZoom = " false " :viewport="{width: 200, height: 200, type: 'circle'}" @result = " fn " 比; & lt; / vue-croppie> API 所有的属性和方法都基于农作物文档。如果你明白我的意思,那么所有的属性和方法名都是"==="。 除了下面的几件事。 选项 类型 默认的 描述 裁判(必需) 对象 没有一个 ref用于创建对子组件的引用,以便访问它的方法和属性。具体的例子是从组件外部访问vue-croppie的result()函数。 resultType 字符串 base64 通过result()对被裁剪的图像进行编码。也可在Croppie文档。 customClass 字符串 没有一个 您可以传递一个或多个自定义类到道具customClass,如customClass="class1 class2 class3" 事件 选项 类型 使用 描述 更新 函数 @update = " fn " 当作物元素被缩放、拖动或裁剪时触发 结果 函数 @result = " fn " 当图像被裁剪时触发。返回裁剪的图像。 注意: $ref . croppieref .result({}). $ref . croppieref .result(})。在这里看到的 常见问题解答 如何清除/销毁副本? 我添加了一个名为refresh()的新方法,可以这样使用。$ref . croppierefs .refresh(),但是croppie实例现在会在每次调用crop()后自动刷新。 有用的链接 358 -官方农作物网页。 更新 1.3.0 - 2017年8月16日 添加webpack构建 修复# 5 修复# 14 1.2.5 - 2017年8月12日 裁剪的图像输出现在可以通过vue事件检索。 添加结果事件。 添加更新的事件。 1.2.3 增加了每次调用crop()后自动刷新croppie实例的功能。 新的方法refresh(),它会破坏和重新创建croppie实例。 1.2.x 结果选项现在通过this.$ref . croppieref传递。结果(选择,回调)。 许可证 麻省理工学院 使用和滥用自负风险。 & lt; / p>与️Jofferson Ramirez Tiquez本文转载于:http://www.diyabc.com/frontweb/news33284.html

VueCroppie的更多相关文章

  1. # BlackLivesMatter !

    下载 # BlackLivesMatter ! https://blacklivesmatter.com/ 黑人的生命是重要的运动资源 VueCroppie VueCroppie是一个Vue 2包装C ...

  2. Croppie -一个Javascript图像Croppie

    下载 Croppie -一个Javascript图像CroppieCroppie -一个Javascript图像Croppie 安装 凉棚:凉棚安装作物 Npm: Npm安装作物 下载: croppi ...

随机推荐

  1. Codeforces1249E By Elevator or Stairs?

    题意 给定整数c和数组a,b,\(a_i\)表示通过爬楼梯的方法从第\(i\)层到\(i+1\)层需要的时间,\(b_i\)表示通过坐电梯的方法从第\(i\)层到\(i+1\)层需要的时间,坐电梯前需 ...

  2. UEFI、BIOS、GPT、MBR等概念的辨析

    (本文转移自本人的旧博客) 从各个地方包括知乎,Wiki,CSDN搜索到的一些整理,这些概念极易混淆. 先说互相的关系 BIOS和UEFI是两种固件接口标准 MBR和GPT是两种分区表 Legacy模 ...

  3. 用于测试 JsonAnalyzer2 1.01版的测试用例

    14. 原文={"animal":"ca,t","color":"ora:nge","isMale" ...

  4. leetcode刷题-62不同路径

    题目 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为“Finish”). 问总 ...

  5. SpringMVC-Controller&RestFul

    Controller与RestFul 目录 Controller与RestFul 1. Controller 1. 控制器Controller 2. 利用接口定义控制器 1. 实现Controller ...

  6. 【小白学PyTorch】9 tensor数据结构与存储结构

    文章来自微信公众号[机器学习炼丹术]. 上一节课,讲解了MNIST图像分类的一个小实战,现在我们继续深入学习一下pytorch的一些有的没的的小知识来作为只是储备. 参考目录: @ 目录 1 pyto ...

  7. python之类方法和静态方法

    在类中定义的函数称为方法,主要有三种:实例方法.类方法.静态方法. class MyTest(): # 普通实例函数 def func1(self, arg1, arg2): pass # 类函数 @ ...

  8. robotframework安装与运行(ride.py1.7.4.2命令报错)(win10+python3.8.1)

    首先,robotframework必须在python的环境下运行 所以你的电脑里必须有python3.x的环境先. 上古时期的robotframework只支持python2,不过python2都已经 ...

  9. 第2课 - 初识makefile的结构

    第2课 - 初识makefile的结构 1. makefile 的意义 (1)makefile 用于定义源文件之间的依赖关系 (在阅读开源软件源码时,可通过Makefile掌握源码中各个文件之间的关系 ...

  10. Linux实战(12):解决Centos7 docker 无法自动补全

    环境:centos最小化安装,会出现一些命令无法自动补全的情况,例如在docker start 无法自动补全 start 命令,无法自动补全docker容器名字.出现这种情况的可参考以下操作: yum ...