RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 878719
Accepted
Pavel8289
Pavel8289
Asked:2020-09-08 01:04:04 +0000 UTC2020-09-08 01:04:04 +0000 UTC 2020-09-08 01:04:04 +0000 UTC

N次后换图

  • 772

这个想法是写一个滑块,这样在 N 次之后,带有文本的图片就会变成另一张幻灯片,等等。在一个圆圈中,也可以使用 dotnav 在前后滚动幻灯片。在 JQ 上,我会很快做所有事情,但使用 Vue 并仅使用它不会很快奏效。

N次后,在“li”标签中写入活动类,删除前一个,它应该与dotnav对称。谁能为此提供建议或帮助?感谢大家的回应!

var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!',
            items: [
                {
                    title: 'Center of osteopatia and rehabilitation',
                    url_img: 'https://i.imgur.com/gQp3VSW.jpg',
                    info_block: [
                        {
                            incremental: '+800%',
                            description: 'Increasing the number of transactions from organic search results'
                        },
                        {
                            incremental: '+240%',
                            description: 'Raising your revenue'
                        }

                    ]
                },
                {
                    title: 'SLide 2',
                    url_img: 'https://newevolutiondesigns.com/images/freebies/space-wallpaper-5.jpg',
                    info_block: [
                        {
                            incremental: '+140%',
                            description: 'Increasing the numb organic search results'
                        },
                        {
                            incremental: '+790%',
                            description: 'Raising your revenue'
                        }

                    ]
                },
                {
                    title: ' SLIDE 3',
                    url_img: 'https://www.planwallpaper.com/static/images/4433836-space-wallpapers.jpg',
                    info_block: [
                        {
                            incremental: '+110%',
                            description: 'Increasing the number of trans'
                        },
                        {
                            incremental: '+99%',
                            description: 'Raising your revenue'
                        }

                    ]
                }
            ]
        },

        methods: {
            index_dotnav:function (index) {
                console.log(index);

            }


        }


    })
    ul{
        padding-left: 0;
        margin: 0;
    }
    .img-block,
    section > *,
    .uk-slideshow,
    .uk-slideshow > ul {
        height: 100vh !important;
    }

    .information-slide .uk-container {
        position: absolute;
        z-index: 1;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        margin: auto 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        color: #fff;
    }

    .slideshow > div.dotnav-block {
        top: 50%;
        left: 95%;

        z-index: 2;
    }

    .slideshow > div.dotnav-block li a {
        background: #fff;
    }

    .slideshow > div.dotnav-block li.active a {
        width: 13px;
        height: 13px;
    }

    .slideshow > div.dotnav-block ul {
        align-items: center;
    }

    .slideshow .slideshow-items > li {
        display: none;
    }

    .slideshow .slideshow-items > li.active {
        display: block;
        position: relative;
    }

    .slideshow .slideshow-items > li img {
        height: 100%;
        width: auto;
        object-fit: cover;
    }
<!DOCTYPE html>
<html>
<head>
    <title>Тест</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/css/uikit.min.css"/>


</head>




<body>
<div id="app">
    <section>
        <div class="uk-child-width-1-2" uk-grid>
            <div>
                <h1>{{ message }}</h1>
            </div>
            <div>
                <div class="slideshow">

                    <ul class="slideshow-items">

                        <li v-for="(item,index) in items"  :class="{'active':index===0}" v-on:click="select($event)">

                            <div class="information-slide">
                                <div class="img-block">
                                    <img v-bind:src="item.url_img" alt="">
                                </div>
                                <div class="uk-container">
                                    <div class="title title-1">{{item.title}}</div>
                                    <div class="info-block">
                                        <div class="info" v-for="(iblock,ind) in item.info_block">
                                            <div class="incremental">{{iblock.incremental}}</div>
                                            <div class="description descr-1">{{iblock.description}}</div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </li>
                    </ul>

                    <div class="dotnav-block uk-position-bottom-center uk-position-small">
                        <ul class="uk-dotnav uk-dotnav-vertical">
                            <li :class="{'active':index===0}"   v-for="(item,index) in items" v-on:click="index_dotnav(index)">
                                <a href="#">Item {{index}}</a></li>

                        </ul>
                    </div>

                </div>

            </div>

        </div>
    </section>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/js/uikit.min.js"></script>


</body>

</html>

vue.js
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    Илья Зеленько
    2020-09-08T01:46:09Z2020-09-08T01:46:09Z

    您需要存储所选元素的索引(在这种情况下, c 在 data 中创建selectedIndex)并更改它。为了每 2 秒创建一个滑动开关,我创建了一个函数setMyTimeout.

    var app = new Vue({
            el: '#app',
            data: () => ({
                message: 'Hello Vue!',
                selectedIndex: 0,
                items: [
                    {
                        title: 'Center of osteopatia and rehabilitation',
                        url_img: 'https://i.imgur.com/gQp3VSW.jpg',
                        info_block: [
                            {
                                incremental: '+800%',
                                description: 'Increasing the number of transactions from organic search results'
                            },
                            {
                                incremental: '+240%',
                                description: 'Raising your revenue'
                            }
    
                        ]
                    },
                    {
                        title: 'SLide 2',
                        url_img: 'https://newevolutiondesigns.com/images/freebies/space-wallpaper-5.jpg',
                        info_block: [
                            {
                                incremental: '+140%',
                                description: 'Increasing the numb organic search results'
                            },
                            {
                                incremental: '+790%',
                                description: 'Raising your revenue'
                            }
    
                        ]
                    },
                    {
                        title: ' SLIDE 3',
                        url_img: 'https://www.planwallpaper.com/static/images/4433836-space-wallpapers.jpg',
                        info_block: [
                            {
                                incremental: '+110%',
                                description: 'Increasing the number of trans'
                            },
                            {
                                incremental: '+99%',
                                description: 'Raising your revenue'
                            }
    
                        ]
                    }
                ]
            }),
    
            methods: {
                select (index) {
                  this.selectedIndex = index
                },
                index_dotnav:function (index) {
                    this.selectedIndex = index
    
                },
                setMyTimeout () {
                  setTimeout(() => {
                    if (++this.selectedIndex === this.items.length) {
                      this.selectedIndex = 0
                    }
                    
                    this.setMyTimeout()
                  }, 2000)
                }
            },
            mounted () {
              this.setMyTimeout()
              
            }
    
    
        })
    ul{
            padding-left: 0;
            margin: 0;
        }
        .img-block,
        section > *,
        .uk-slideshow,
        .uk-slideshow > ul {
            height: 100vh !important;
        }
    
        .information-slide .uk-container {
            position: absolute;
            z-index: 1;
            top: 0;
            bottom: 0;
            right: 0;
            left: 0;
            margin: auto 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            color: #fff;
        }
    
        .slideshow > div.dotnav-block {
            top: 50%;
            left: 95%;
    
            z-index: 2;
        }
    
        .slideshow > div.dotnav-block li a {
            background: #fff;
        }
    
        .slideshow > div.dotnav-block li.active a {
            width: 13px;
            height: 13px;
        }
    
        .slideshow > div.dotnav-block ul {
            align-items: center;
        }
    
        .slideshow .slideshow-items > li {
            display: none;
        }
    
        .slideshow .slideshow-items > li.active {
            display: block;
            position: relative;
        }
    
        .slideshow .slideshow-items > li img {
            height: 100%;
            width: auto;
            object-fit: cover;
        }
    <div id="app">
        <section>
            <div class="uk-child-width-1-2" uk-grid>
                <div>
                    <h1>{{ message }}</h1>
                </div>
                <div>
                    <div class="slideshow">
    
                        <ul class="slideshow-items">
    
                            <li v-for="(item,index) in items"  :class="{'active':index===selectedIndex}" v-on:click="select(index)">
    
                                <div class="information-slide">
                                    <div class="img-block">
                                        <img v-bind:src="item.url_img" alt="">
                                    </div>
                                    <div class="uk-container">
                                        <div class="title title-1">{{item.title}}</div>
                                        <div class="info-block">
                                            <div class="info" v-for="(iblock,ind) in item.info_block">
                                                <div class="incremental">{{iblock.incremental}}</div>
                                                <div class="description descr-1">{{iblock.description}}</div>
                                            </div>
                                        </div>
    
                                    </div>
                                </div>
                            </li>
                        </ul>
    
                        <div class="dotnav-block uk-position-bottom-center uk-position-small">
                            <ul class="uk-dotnav uk-dotnav-vertical">
                                <li :class="{'active':index===selectedIndex}"   v-for="(item,index) in items" v-on:click="index_dotnav(index)">
                                    <a href="#">Item {{index}}</a></li>
    
                            </ul>
                        </div>
    
                    </div>
    
                </div>
    
            </div>
        </section>
    </div>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/css/uikit.min.css"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-rc.14/js/uikit.min.js"></script>

    • 1

相关问题

  • 带分页的 Vuejs 网格 (Pagination)

  • 如何将道具传递给使用“组件”伪元素呈现的组件?

  • Vue.js 网格组件示例更改列名称

  • VueJS 不渲染列表

  • vue js 不从 $data 更新参数

  • Vue js 循环使用组件

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    是否可以在 C++ 中继承类 <---> 结构?

    • 2 个回答
  • Marko Smith

    这种神经网络架构适合文本分类吗?

    • 1 个回答
  • Marko Smith

    为什么分配的工作方式不同?

    • 3 个回答
  • Marko Smith

    控制台中的光标坐标

    • 1 个回答
  • Marko Smith

    如何在 C++ 中删除类的实例?

    • 4 个回答
  • Marko Smith

    点是否属于线段的问题

    • 2 个回答
  • Marko Smith

    json结构错误

    • 1 个回答
  • Marko Smith

    ServiceWorker 中的“获取”事件

    • 1 个回答
  • Marko Smith

    c ++控制台应用程序exe文件[重复]

    • 1 个回答
  • Marko Smith

    按多列从sql表中选择

    • 1 个回答
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Suvitruf - Andrei Apanasik 什么是空? 2020-08-21 01:48:09 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5