vuejs小例子之实现图片的切换

前端开发 作者: 2024-08-26 09:45:01
代码: <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"
<html>

head>
  script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></scriptstyle>
    #app {
      border: 1px solid red;
      left: 50%;
      top: 50%;
      width: 410px;
      height: 235px;
    }

    .bg {
      position: relative;
      top: 5px;
      left: 5px;
    }

    .left {
      position: absolute;
      top: 104px;
      left: 15px;
    }

    .lbg {
      height: 80px;
      width: 30px;
      opacity: 0.8;
    }

    .right {
      position: absolute;
      top: 104px;
      left: 382px;
    }

    .rbg {
      height: 80px;
      width: 30px;
      opacity: 0.8;
    }
  </>
bodydiv id="app">
    img :src="imgurl[index]" alt="" class="bg"span>
      a href="#"="left" @click="prev" v-show="index!=0">
        =" ./img/left.jpg "=" "="lbg "a="# "="right "="next "="index<imgurl.length-1"="./img/right.jpg "="rbg "div
    var app = new Vue({
      el: '#app',data: {
        imgurl: ["./img/img1.jpg ","./img/img2.jpg ","./img/img3.jpg ","./img/img4.jpg "],index: 0,},methods: {
        prev: function () {
          this.index -= 1;
        },next: function () {
          this.index += 1;
        }
      },})
  >
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_68904.html