vue实现图片分页

本小节学会使用v-show@clickv-bindv-bind可以简写为:

DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Documenttitle>
head>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js">script>

<body>
  <div id="app">
    <button v-show="index>0" @click="index--">上一页button>
    <div>
      <img :src="list[index]">
    div>
    <button v-show="index < list.length-1" @click="index++">下一页button>
  div>

  <script>
    const app = new Vue({
      el: '#app',
      data: {
        index: 0,
        list: [
          './imgs/001.png',
          './imgs/002.png',
          './imgs/003.png',
          './imgs/004.png'
        ]
      }
    })
  script>
body>

html>

你可能感兴趣的:(前端,vue.js,前端,javascript)