zoukankan      html  css  js  c++  java
  • -_-#【Backbone】Router

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <link rel="stylesheet" href="../../app-min.css">
    </head>
    <body>
        <a href="#actions">testActions</a>
        <a href="#/posts/120">Post 120</a>
        <a href="#/download/user/images/hey.gif">download gif</a>
        <a href="#/dashboard/graph">Load Route/Action View</a>
        <script src="../../jquery/jquery-1.10.2.js"></script>
        <script src="../underscore.js"></script>
        <script src="../backbone.js"></script>
        <script>
            var AppRouter = Backbone.Router.extend({
                routes: {
                    "posts/:id": "getPost",
                    "download/*path": "downloadFile",
                    ":route/:action": "loadView",
                    "*actions": "defaultRoute"
                },
                getPost: function(id) {
                    console.log(id)
                },
                defaultRoute: function(actions) {
                    console.log(actions)
                },
                downloadFile: function(path) {
                    console.log(path)
                },
                loadView: function(route, action) {
                    console.log(route + '_' + action)
                    app_router.navigate("/posts/" + 404, {trigger: true, replace: true})
                }
            })
            var app_router = new AppRouter
            Backbone.history.start()
        </script>
        <article class="content">
            <pre>var AppRouter = Backbone.Router.extend({
        routes: {
            "posts/:id": "getPost",
            "download/*path": "downloadFile",
            ":route/:action": "loadView",
            "*actions": "defaultRoute"
        },
        getPost: function(id) {
            console.log(id)
        },
        defaultRoute: function(actions) {
            console.log(actions)
        },
        downloadFile: function(path) {
            console.log(path)
        },
        loadView: function(route, action) {
            console.log(route + '_' + action)
            app_router.navigate("/posts/" + 404, {trigger: true, replace: true})
        }
    })
    var app_router = new AppRouter
    Backbone.history.start()</pre>
        </article>
    </body>
    </html>
  • 相关阅读:
    android个人中心界面
    开课第十二周周总结
    android----从相册中选择照片
    《程序员修炼之道:从小工到专家》 阅读笔记
    android----pull解析方式
    开课第十一周周总结
    解决数据库连接时区的问题
    实现数组中连续子数组值和最大
    开课第十周周总结
    解 idea(.IntelliJIdea2019.3)双击打不开的原因
  • 原文地址:https://www.cnblogs.com/jzm17173/p/4171838.html
Copyright © 2011-2022 走看看