下载

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. windows环境下利用Gitblit搭建Git服务器并实现自动部署Web站点目录

    Git服务搭建多见于linux环境,但windows主机也不少,目前网上文章诸多不全,且以讹传讹,不甚清楚.下面介绍windows环境下的自动部署和发布. 所需环境及资源:Java环境.Gitblit ...

  2. 伪距定位算法(matlab版)

    在各种伪距定位算法中,最小二乘法是一种比较简单而广泛的方法,该算法可以分为以下几步: 1.准备数据与设置初始值 这里准备数据,主要是对于各颗可见卫星,收集到它们在同一时刻的伪距测量值,计算测量值的各项 ...

  3. <init>与<clinit>,static与final与static final

    <init>和<clinit> init是对象构造器方法,初始化对象的时候执行 clinit是类构造器方法,类加载的初始化阶段执行 final常量赋值(必须是一下其中一种) 显 ...

  4. C# 获取当前月的月初和月末

    /// <summary> /// 获取当前月的月末日期 /// </summary> /// <returns></returns> public s ...

  5. C003:计算球体体积 自行输入球体半径

    程序: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { float sphereRadius; do{ pri ...

  6. Agumaster 增加股票表台账页面

  7. 哦!这该死的 C 语言

    前言 C 语言是一门抽象的.面向过程的语言,C 语言广泛应用于底层开发,C 语言在计算机体系中占据着不可替代的作用,可以说 C 语言是编程的基础,也就是说,不管你学习任何语言,都应该把 C 语言放在首 ...

  8. [LeetCode]21. 合并两个有序链表(递归)

    题目 将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1->2->4, 1->3->4 输出:1->1-> ...

  9. 自然常数e的含义

    e是一个重要的常数,但是它的直观含义却不像 π 那么明了.我们都知道,圆的周长与直径之比是一个常数,这个常数被称为圆周率,记作 π = 3.14159......可是e代表什么呢? e是“指数”(ex ...

  10. .NetCore之接口缓存

    1.问题:我们平时做开发的时候肯定都有用到缓存这个功能,一般写法是在需要的业务代码里读取缓存.判断是否存在.不存在则读取数据库再设置缓存这样一个步骤.但是如果我们有很多地方业务都有用到缓存,我们就需要 ...