国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Vue.js實(shí)現圖片切換功能

發(fā)布時(shí)間:2021-08-17 12:16 來(lái)源: 閱讀:0 作者:一個(gè)愛(ài)前端開(kāi)發(fā)的小朋友 欄目: JavaScript 歡迎投稿:712375056

本文實(shí)例為大家分享了Vue.js實(shí)現圖片切換功能的具體代碼,供大家參考,具體內容如下

實(shí)現功能如下

文件目錄如下,要實(shí)現本功能只需要修改圖片的存儲位置即可

代碼如下

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <title></title>
  <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
 </head>
 <style type="text/css">
  div {
   margin: 0 auto;
   width:200px;
   height: 300px;
   border: 1px solid aqua;
  }
  img {
   margin: 0 auto;
   width: 200px;
   height: 250px;
   border: 1px solid aqua;
  }
  
 
 </style>
 <body>
  <div id="app">
   <img :src="imgSrc[index]" >
   <button type="button" @click="prephoto()">上一張</button>
   <button type="button" @click="nextphoto()">下一張</button>
  </div>
  <script type="text/javascript">
   var app  = new Vue({
    el:"#app",
    data:{
             imgSrc:["./img/1.jpg","./img/2.jpg"],
    index:1
    },
    methods:{
     prephoto:function(){
      this.index--;
      if(this.index===-1)
      {
       this.index=this.imgSrc.length-1;
      }
      console.log(this.index)
     },
     nextphoto:function(){
      this.index++;
      if(this.index===this.imgSrc.length){
       this.index=0;
      }
      console.log(this.index)
     }
    }
   })
  </script>
 </body>
</html>

適合初學(xué)者。

以上就是本文的全部?jì)热?,希望對大家的學(xué)習有所幫助,也希望大家多多支持腳本之家。

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

久久精品国产亚洲AVAPP下载| 伊人久久大香线蕉AV不变影院| 国产96色在线 | 国| 国产精品老熟女露脸视频| 中文日韩亚洲欧美制服| 色综合色综合久久综合频道88|