我有一个这样的对象:
this.$
- 它保存了包含数组的索引。例如,它有两个不同的索引:一个称为 slide
,另一个称为 thumb
。这些索引保存数组。
我正在使用 vue 进行开发,并使用 v-ref
属性显示它们。但是,每当我执行以下操作:
console.log(this.$.slide.length)
它返回为0。我试图使用 forEach()
循环遍历它,但无法,因为它显示为 0,即使该数组中明显有4个 VueComponent 对象。
我真的不明白为什么它说 slide: array[0],但下一行显示 slide: array[4]。我尝试进入 this.$.slide.slide
,但那是未定义的。
感谢您的任何见解。
编辑:
这是我的 Vue HTML 代码:
<slider inline-template img-count="4" v-ref="slider">
<div class="slides" v-style="styles">
<sliderslide v-repeat="count" v-ref="slide">
<img src="{{ gallery_image('HM722_Silver_Creek_9978.jpg', 'full') }}" alt="HM722 Silver Creek" style="margin-top:-15%;" />
</sliderslide>
</div>
<div class="thumbnails">
<div class="thumbnail-wrapper">
<sliderthumb v-repeat="count" send-index="@{{ updateIndex }}" v-ref="thumb"
image-src="{{ gallery_image('HM722_Silver_Creek_9978.jpg') }}"
image-alt=""
caption="Newest Product">
</sliderthumb>
</div>
</div>
</slider>
已经存在,因此应该显示它们...
我在Vue的ready
方法中使用console.log()打印所有内容。
console.log
之后以及Vue尝试以其正在尝试的任何方式使用它们之后添加到数组中。 - James Thorpeconsole.log(this.$.slide)
显示什么? - Tro