我将一组图像文件路径传递给组件.我想知道如果我传递一个不同的数组,在Vue.js组件中观察道具更改的最佳方法是什么?
我正在使用自举旋转木马,所以想要在阵列发生变化时将其重置为第一张图像.为了简单起见,我将代码示例简化为:
Vue.component('my-images', {
props: ['images'],
template: `
<section>
<div v-for="(image, index) in images">
{{index}} - <img :src="image"/>
</div>
</section>
`
});
Run Code Online (Sandbox Code Playgroud)