Vue.js Vuejs-抓取传递到组件模板的项
我的标记如下所示:Vue.js Vuejs-抓取传递到组件模板的项,vue.js,Vue.js,我的标记如下所示: <slider> <img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" /> <img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silv
<slider>
<img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" />
<img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" />
<img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" />
<img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" />
</slider>
这些方法仍然很混乱,所以忽略它们,但我想尝试对传入的img标记进行v-repeat,因为它们将通过@foreach功能循环。所以不会总是有一个明确的4。。data属性的slideLength为4,模板有4个区域,但我真正想要的是循环遍历传递到模板中的任何图像
感谢您的指点。我似乎已经通过向组件传递道具来克服这一问题,如下所示:
<slider img-count="4">
我似乎已经通过向组件传递一个道具来克服了这一点,但我不确定如何循环通过它们…:
,然后在我的组件中使用this.imgCount
访问它。我不知道为什么我以前没有想到这个!
<slider img-count="4">
<script type="text/x-template" id="homepage-slideshow">
<div class="slides" style="width:@{{ sliderWidth }}px">
<article v-repeat="count" id="slide@{{ $index }}" class="slide" style="width:@{{ slideWidth }}px;height:@{{ height }}px">
<content select="img:nth-of-type(@{{ $index + 1 }})"></content>
</article>
</div>
<div class="thumbnails">
<div class="thumbnail-wrapper container">
<img v-repeat="count" src="/img/thumbnail.png" data-slide="slide@{{ $index }}" v-on="click: thumbnailClick" style="height:@{{ thumbnailHeight }}px" />
</div>
</div>
</script>