“Vue 图片切换”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
第17行: 第17行:
 
     imgArr:[],
 
     imgArr:[],
 
     index:0
 
     index:0
 +
  },
 +
  methods:{
 +
    prev:function(){},
 +
    next:function(){}
 
   }
 
   }
 
})
 
})
 
</syntaxhighlight>
 
</syntaxhighlight>

2023年8月8日 (二) 02:26的版本

https://www.bilibili.com/video/BV12J411m7MG/?p=14

1.定义图片数组

2.添加图片索引

3.绑定 src 属性

<div id="#app">
    <img :src="imgArr[index]">
    <a href="#">上一张</a>
    <a href="#">下一张</a>
</div>
var app = new Vue({
  el:"#app",
  data:{
    imgArr:[],
    index:0
  },
  methods:{
    prev:function(){},
    next:function(){}
  }
})