翻了下api 没有找到对应的属性,所以这里用方法来实现
这里的 autoHeight 就是高度,height属性钱前面要有 :
<el-carousel :interval="5000" arrow="never" :height="autoHeight">
<el-carousel-item v-for="(banner, index) in banners" :key="index">
<a :href="banner.extra.tourl">
<img :src="banner.imgurl" :title="banner.title" class="max-img">
</a>
</el-carousel-item>
</el-carousel>
我们取的banner 是在750像素下高度为145px
getAutoHeight(){
let _w = document.documentElement.clientWidth || document.body.clientWidth; ;
this.autoHeight = _w * 145 / 375 + 'px';
}