【发布时间】:2020-03-24 17:30:23
【问题描述】:
这是一个非常奇怪的行为,我不知道该怎么做,我正在建立一个使用 Vue.js 和 CropperJs 裁剪图像的网站,在主页上用户选择他们想要裁剪的图像并点击'继续',下一页显示了一个名为ImageCropper.vue的组件,画布和所有内容都显示成功,但它很小,但是假设我编辑了html,即使我只添加了一个空行,图像也会恢复到它的大小应该是(我没有预定义的尺寸,所以它只需要 100% 的容器宽度,高度是自动的,我想。)
ImageCropper.vue
<template>
<div class="image-container">
<img ref="image" :src="source">
</div>
</template>
<script>
import Cropper from 'cropperjs'
export default {
name: "ImageCropper",
props: ["source"],
data() {
return {
cropper: null,
imageElement: null
}
},
mounted() {
this.imageElement = this.$refs.image
this.cropper = new Cropper(this.imageElement, {
aspectRatio: 1
})
}
}
</script>
我尝试使用 css 对其进行样式设置,但似乎没有任何效果,也许我使用 vue 的方式有问题?这是带有 Vuetify 的 Vue,如果这很重要的话。
【问题讨论】:
标签: javascript vue.js vuetify.js cropperjs