我使用vue.js和OwlCarousel,每次我使用v-for與旋轉木馬時,它都不會顯示旋轉木馬的樣式,它只顯示列中的圖像。使用OwlCarousel與Vue.js的問題
這請求的API:
<script>
export default {
data: {
videos_p: []
},
mounted() {
axios.get("xxxxxxxxxxx")
.then(response => {
this.videos_p = response.data
console.log(this.videos_p)
})
}
}
$(document).ready(function() {
var owl = $('.owl-carousel');
owl.owlCarousel({
items: 4,
loop: true,
margin: 10,
autoplay: true,
autoplayTimeout: 900,
autoplayHoverPause: true,
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 3,
nav: false
},
1000: {
items: 5,
nav: true,
loop: false,
margin: 20
}
}
});
})
</script>
,這是HTML:
<section id="demos">
<div class="row">
<div class="large-12 columns">
<div class="owl-carousel owl-theme">
<div class="item" v-for="video in videos_p">
<img v-bind:src="video.image_url">
</div>
</div>
</div>
</div>
</section>
但每次我用它VUE時間不顯示我的旋轉木馬,只告訴我在列中的圖像,但如果我使用這樣的例子,它工作正常:
<section id="demos">
<div class="row">
<div class="large-12 columns">
<div class="owl-carousel owl-theme">
<div class="item">
<img src="http://placehold.it/300x150&text=FooBar1">
</div>
<div class="item">
<img src="http://placehold.it/300x150&text=FooBar1">
</div>
<div class="item">
<img src="http://placehold.it/300x150&text=FooBar1">
</div>
<div class="item">
<img src="http://placehold.it/300x150&text=FooBar1">
</div>
<div class="item">
<img src="http://placehold.it/300x150&text=FooBar1">
</div> -->
</div>
</div>
</div>
</section>
任何想法,我在做一個mistak ê?????
嘗試在Vue完成安裝結構後調用'$(document).ready'中的內容。 – yuriy636
你有沒有例子?因爲我在掛載()完成後添加函數,並且它不顯示圖像或任何東西 –
嘗試將它放在'updated()'中,這樣當Vue由於axios請求更新標記時,傳送帶將初始化。 – yuriy636