是否有任何人有使用流星的經驗?在通過彈弓上傳圖像之後,在Meteor js中使用Cropit
我想通過彈弓將圖像發送到S3之前裁剪圖像。
所以我安裝cropit與
meteor add suxez:jquery-cropit
,並根據cropit的官方網站,我想補充
<div class="image-editor">
<input type="file" class="cropit-image-input">
<div class="cropit-preview"></div>
<div class="image-size-label">
Resize image
</div>
<input type="range" class="cropit-image-zoom-input">
<button class="rotate-ccw">Rotate counterclockwise</button>
<button class="rotate-cw">Rotate clockwise</button>
<button class="export">Export</button>
</div>
我的模板,
Template.XXXXXX.onCreated(function() {
$('.image-editor').cropit({
exportZoom: 1.25,
imageBackground: true,
imageBackgroundBorderWidth: 20,
imageState: {
src: 'http://lorempixel.com/500/400/',
},
});
我onCreated功能可按,並添加
'click .rotate-cw': function() {
$('.image-editor').cropit('rotateCW');
},
'click .rotate-ccw': function() {
$('.image-editor').cropit('rotateCCW');
},
'click .export': function() {
var imageData = $('.image-editor').cropit('export');
window.open(imageData);
},
我的模板事件。最後
.cropit-preview {
background-color: #f8f8f8;
background-size: cover;
border: 5px solid #ccc;
border-radius: 3px;
margin-top: 7px;
width: 250px;
height: 250px;
}
.cropit-preview-image-container {
cursor: move;
}
.cropit-preview-background {
opacity: .2;
cursor: auto;
}
.image-size-label {
margin-top: 10px;
}
input, .export {
/* Use relative position to prevent from being covered by image background */
position: relative;
z-index: 10;
display: block;
}
button {
margin-top: 10px;
}
我的CSS ....但是,這並不在所有的工作.... 我試圖通過點擊上傳按鈕, 上傳圖片,但沒有預覽...和出口按鈕不工作......
任何人都可以幫助我,請這? :)
是否有任何錯誤在瀏覽器的控制檯中? – CodeChimp
不是真的,有一個錯誤「無法解析SourceMap:http:// localhost:2323/packages/0f7c38a73e1fd696f71cacdd4284e82d601d2fc5.map」,但我認爲它應該是不相關的。 – Nan
我也嘗試直接使用一些靜態HTML頁面的裁剪,它工作得很好,所以我認爲這個問題來自於我沒有設置好一切與流星@@ – Nan