【问题标题】:I don't want bootstrap tour to start on second visit我不想在第二次访问时开始引导之旅
【发布时间】:2015-02-12 14:21:33
【问题描述】:

我正在使用引导程序浏览进行页面浏览。我想要做的是在您访问页面后自动开始游览,但在下次访问时,游览不应该自动开始,而是在您单击按钮时自动开始。我猜这可以通过“存储”来完成,但我不知道如何。有人可以帮忙吗?谢谢

【问题讨论】:

    标签: twitter-bootstrap bootstrap-tour


    【解决方案1】:

    'storage' 需要是 'window.localStorage'。此值为默认值,因此您无需添加任何选项。

    // Instance the tour
    var tour = new Tour();
    
    tour.addSteps([
         {
            element: "#one",
            title: "First",
            content: "First Content",
            placement: "right"
        }, {
            element: "#two",
            title: "Second",
            content: "Second content",
            placement: "right"
        }
    ]);
    
    tour.init();
    tour.start();
    
    $("#startTour").click(function () {
        tour.restart();
    })
    div#one {
        padding:20px;
        margin:50px;
        width:100px;
        height:100px;
        background-color:gray;
    }
    div#two {
        padding:20px;
        margin:50px;
        width:100px;
        height:100px;
        background-color:aqua;
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.css" rel="stylesheet"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.10.1/css/bootstrap-tour.css" rel="stylesheet"/>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.10.1/js/bootstrap-tour.js"></script>
    
    <div id="one">First step</div>
    <br>
    <div id="two">Second step</div>
        
        <div>
            <button id="startTour" class="btn btn-success">Start</button>
        </div>

    【讨论】:

      【解决方案2】:

      我们应该会遇到同样的问题,请在此处查看我的问题和答案:Bootstrap tour needs to clear cache to work again

      使用restart()代替start()或者设置“storage: false”可以解决问题。

      【讨论】:

        猜你喜欢
        • 2013-10-16
        • 1970-01-01
        • 2014-08-08
        • 1970-01-01
        • 1970-01-01
        • 2011-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多