我一起使用cropper和caman都有问题。 我复制了fengyanchen提供的代码,并为Meteor修改了一下。 Caman可以工作,但是裁剪器没有启动。
代码: http://codepen.io/chenfengyuan/pen/wMrVQY
HTML
<template name="Test">
{{ > index }}
<div class="container">
<h1 class="page-header">Use Cropper with CamanJS</h1>
<p id="upload">
<input id="file" type="file">
</p>
<p id="handle" style="display:none">
<button class="btn btn-primary" id="brightness">Brightness</button>
<button class="btn btn-primary" id="contrast">Contrast</button>
</p>
<p>
<canvas id="canvas" style="max-width:100%;"></canvas>
</p>
</div>
我的事件处理程序:
...(链接中提供的功能已复制)
Template.Test.events({
'change #file':function(event,template){
if (URL) {
var files = event.target.files;
var file;
if (files && files.length) {
file = files[0];
if (/^image\/\w+$/.test(file.type)) {
startCaman(URL.createObjectURL(file));
} else {
window.alert('Please choose an image file.');
}
}
} else {
$file.prop('disabled', true);
}
}
})
答案 0 :(得分:0)
当我做以下事情时,它起了作用:
赋予画布宽度和宽度高度
删除最顶层的var $ canvas并将其替换为真正的画布选择器无处不在