zoukankan      html  css  js  c++  java
  • 前端路由

    router

    前端路由的框架,通用的有Director,更多还是结合具体框架来用,比如Angular的ngRouter,React的ReactRouter,以及我们后面用到的Vue的vue-router。这也带来了新的开发模式:MVC和MVVM。如今前端也可以MVC了,这也是为什么那么多搞Java的钟爱于Angular。

    director:

    https://github.com/flatiron/director

    参考:

    http://www.cnblogs.com/libin-1/p/5906526.html

    http://www.cnblogs.com/zhuzhenwei918/p/6181760.html#undefined

    jquery的方法

    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    
            <script>
    
                var route = {
                    _routes : {},    // The routes will be stored here
    
                    add    : function(url, action){
                        this._routes[url] = action;
                    },
    
                    run : function(){
                        jQuery.each(this._routes, function(pattern){
                            if(location.href.match(pattern)){
                                // "this" points to the function to be executed
                                this();
                            }
                        });
                    }
                }
    
                // Will execute only on this page:
                route.add('002.html', function(){
                    alert('Hello there!')
                });
    
                route.add('products.html', function(){
                    alert("this won't be executed :(")
                });
    
                // You can even use regex-es:
                route.add('.*.html', function(){
                    alert('This is using a regex!')
                });
    
                route.run();
    
            </script>
  • 相关阅读:
    Probability theory
    python Memo
    numpy 札记
    linux LVM 逻辑卷
    关于TF-IDF的一些见解
    Python之list、dict、np等常用数值运算
    Python之matplotlib绘图
    Python之打开网页
    Python之获取地址经纬度
    两台电脑直接共享文件
  • 原文地址:https://www.cnblogs.com/wang715100018066/p/6186328.html
Copyright © 2011-2022 走看看