Crop events plugin for Vue.js 2.0 Based on VueCrop and Jcrop
This is a directive for Jcrop v0.9.12.
See a live demo here, this demo is for Vue.js 1.0
Firstly, you have to include jQuery
and Jcrop
in you html template.
You can include it with a <script>
tag when you have Vue itself included globally. It will automatically install itself, and will add a global Vue2Crop
.
Available through npm as vue2-crop
.
npm install --save vue2-crop
Use this directive in main.js
import Vue2Crop from 'vue2-crop'
Vue2Crop.setOptions({
bgOpacity: 0.6,
allowResize: true,
allowMove: true,
allowSelect: true
})
Vue.use(Vue2Crop)
Then you can do this:
<img src="pic.jpg" width="600" height="400" v-crop:select="oncrop"/>
You should specify both the
height
andwidth
attributes
See Jcrop documentation for all available events.
Vue2Crop.setOptions({
bgOpacity: 0.6,
allowResize: true,
allowMove: true,
allowSelect: true
})
See Jcrop documentation for all available options.
Vue2Crop is released under the MIT Licence. See the bundled LICENSE file for details.