• -_-#【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>
  • 相关阅读:
    限时购校验小工具&dubbo异步调用实现限
    Android 应用防止被二次打包指南
    什么是高防服务器?
    真屏实据丨数据大屏设计实战—揭秘企业级数据大屏设计过程
    TerminateThread函数学习
    HTML DOM访问
    gdb常用命令
    整数开方算法
    android环境下解决java.io.IOException: Malformed ipv6异常的方法
    HTML DOM 创建与修改
  • 原文地址:https://www.cnblogs.com/jzm17173/p/4171838.html
Copyright © 2020-2023  润新知