【vue】图片轮播案例

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 图片路径使用模板字符串 -->
        <img :src=`./image${number}.png` style="width: 300px;height: 300px;">
        <hr>
        <button @click="number=number-1;if(number<1){number=3}">上一张图片</button>
        <span>当前图片编号:{{number}}</span>&nbsp;
        <button @click="number=number+1;if(number>3){number=1}">下一张图片</button>
        <!-- 第二种思路 -->
        <hr>
        <ul>
            <li v-for="value in 3">
                <a href="#" @click="number=value">{{value}}</a>
            </li>
        </ul>
        

    </div>

    <script type="module">
        import { createApp, reactive, ref, watchEffect } from './vue.esm-browser.js'
        createApp({
            setup() {
                const number=ref(1)

                return {
                    number
                }
            }
        }).mount("#app")
    </script>
</body>

</html>

参考

https://www.bilibili.com/video/BV1nV411Q7RX

相关推荐

  1. android 图片

    2024-04-13 06:54:03       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-13 06:54:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 06:54:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 06:54:03       82 阅读
  4. Python语言-面向对象

    2024-04-13 06:54:03       91 阅读

热门阅读

  1. Qt - 获取系统当前时间

    2024-04-13 06:54:03       36 阅读
  2. SpringBoot 中的 application.yml 和 bootstrap.yml 的区别

    2024-04-13 06:54:03       40 阅读
  3. 【c++&leetcode】26. Remove Duplicates from Sorted Array

    2024-04-13 06:54:03       35 阅读
  4. 搜索(未完结版)

    2024-04-13 06:54:03       35 阅读
  5. Oracle使用regexp_like报错ORA-12733 正则表达式太长

    2024-04-13 06:54:03       39 阅读
  6. 【Leetcode】正则表达式

    2024-04-13 06:54:03       38 阅读
  7. 下采样-Sobel滤波器等边缘检测滤波器

    2024-04-13 06:54:03       39 阅读
  8. 利用Python进行图像和XML标注数据的批量处理

    2024-04-13 06:54:03       36 阅读
  9. Fiddler的安装和使用

    2024-04-13 06:54:03       38 阅读