Giter Club home page Giter Club logo

router's Issues

请问支持IE8 E9吗?

abc
请问支持IE8 E9吗?

提示: 对象不支持此操作,在这一行报错
Object.defineProperty(t, "__esModule", {
value: !0
});

@progrape

可以实现多级跳转之后,返回到第一个页面吗?

我这边现在在做选择修改学校信息,需要从个人中心到-->省-->市-->县-->学校,在学校页面保存之后, 返回个人中心,如果在保存之后,直接跳转到个人中心,页面是跳转了,但是点返回按钮,又返回到了学校页面,再返回,又到了县一级。
我想学校页面点保存之后直接到个人中心
如果不点保存,返回就到县页面

微信端侧滑bug

我反复测试发现,连续打开3个窗口后,侧滑返回只能两次,在第3个窗口侧滑时看到的是第一个窗口的图像,侧滑完成后页面突然变成了第二个窗口,再次侧滑页面关闭了,应该是返回第一个窗口。
从第3个窗口侧滑返回到第二个窗口时,再侧滑没有了,但是顶上返回键点击有效。
点击顶上的返回按钮就一切都正常!

router子页面加swiper,为何只有第一次有效,离开后再返回变无效了

// home
var home = {
    url: '/',
    className: 'tabbar',
    render: function () {
                    return $('#tpl_home').html();
    },
    bind: function () {
                    swiper = new Swiper({direction: 'horizontal'});
                    $('#container').on('click', '.weui_tabbar_item', function () {
            $(this).addClass('weui_bar_item_on').siblings('.weui_bar_item_on').removeClass('weui_bar_item_on');

                            swiper.next();
        });
    }
};

render是否可以考虑前置逻辑?

比如在render里面,如果return null,就不做内容替换,保留原有的内容.

我们目前的项目遇到一个情况,从home页跳转到page1页面,在page1的render里面执行一些ajax的校验逻辑.假如校验逻辑不通过,我希望保持home的内容不变.

浏览器前进后退按钮点击过快会导致异常

由于监听到hash change立即执行go方法,而go方法在执行过程中会等待转场动画完成后再删除前页的DOM,这就导致过快点击浏览器前进或后退按钮时,与之对应的DOM元素还没有被创建或已经被删除的情况下,再执行removeChild方法抛出异常

点击浏览器返回按钮后,数据变重复

复现方法:
Step 1. 使用浏览器(Chrome on Mac, Safari on Mac, Safari on iOS) 打开 https://github.com/progrape/router
Step 2. 点击预览那里的链接 https://progrape.github.io/router
Step 3. 等待画面加载完成后,点击浏览器的返回按钮,此时会看到画面的数据块重复,每点击一次,多出一块数据。除非你快速点击两次返回按钮(仅Mac)。
(实际上,你点击该 issue 里 Step 2 那里的链接也有同样的效果)

render重复问题

页面间切换 ,快速返回多次会出现上个页面没有卸载 同时出现两个页面
console 报错
router.min.js:formatted:142Uncaught TypeError: Cannot read property 'removeChild' of null

建议调用bind函数时不要使用call

if (typeof route.bind === 'function'/* && !route.__isBind*/) {
             route.bind.call(node);
             //route.__isBind = true;
 }

修改成

if (typeof route.bind === 'function'/* && !route.__isBind*/) {
             route.bind(node);
             //route.__isBind = true;
 }

这样可以在bind函数中使用route对象,可以用来保存一些中间数据。

go方法死循环

使用go方法时,如果目标路由的bind里面有判断,然后手动修改hash,go会强制修改回来,会陷入死循环。
我觉得应该停在手动改的hash那边,或者规定不能在bind里面修改hash,至少不应该死循环。

在bind方法中怎么获取到当前的router信息呢?

Hi jf大神,目前正在使用您的git库中的router,遇到了以下问题想请教一下:
我看了您的todo的example,发现有段代码可以在bind方法中使用this获取到当前的router信息。
3a560rv7as2 l 1v 3n
但是那里面是import了router.js,并不是用了您git上的router:
k 3ex3wu dyv_5 w3 q 3g1
我在使用您git上的router的时候,在bind方法中使用this,返回的是当前的html,请问在bind方法中怎么获取当前的router信息呢?

可以使用ajax页面吗?

或者说是初始化的时候,获取页面上的ajax页面
var toast = {
url: '/toast',
className: 'toast',
render: function () {
return getPage("/usercentertoast.html");
},
bind: function () {
$('#container').on('click', '#showToast', function () {
$('#toast').show();
setTimeout(function () {
$('#toast').hide();
}, 2000);
}).on('click', '#showLoadingToast', function () {
$('#loadingToast').show();
setTimeout(function () {
$('#loadingToast').hide();
}, 2000);
});
}
};

bind 执行两次

手机端首次访问,bind执行两次,如下,会alert两次。

var index = {
url: '/',
className: 'home',
render: function (){
return 'home';
},bind: function () {
alert(1);
}
}

过渡动画的时间问题

点击链接时,在go方法最后会调用一次leave去删除上一个页面,但是这个leave使用的是leaveTimeout而不是enterTimeout,如果我的enterTimeout和leaveTimeout不同的话会引起切换时间错误的问题。
应该修改成根据isBack来判断使用哪个timeout,如果是前进动作就使用enterTimeout。

关于 render 完成后,需要执行一些代码。

render function 是指切换页面前 至最后 return 。
相当于,我做了一些前置工作后,return 才切换页面。

基于传统前端页面思维,我想当 return 切换页面完成时,想要执行一些代码,该如何实现?
类似于原生的 window.load 方法,即页面渲染完成后,我要做一些事。

请楼主提供示例,感谢!

callback用不了?

<script>
    $(function () {

        var router = new Router({
            container: '#container',
            enterTimeout: 250,
            leaveTimeout: 250
        });

        var home = {
            url: '/',
            className: 'home',
            render: function () {
                return $('#home').html();
            }
        };

        var page = {
            url: '/page',
            className: 'page',
            render: function (callback) {
                Wxui.html('/c_Gavm3qM9X.view',function(html){
                    callback(null,html);
                });
            }
        };

        router.push(home)
            .push(page)
            .setDefault('/')
            .init();
    });
</script>

<div id="container">

</div>

<div id="home" style="display:none;">
<a href="#/page">第一页</a><p>首页</p>
</div>

Wxui.html是一个$.ajax的封转.

请求参数必须跟URL配置对应

发现url连接参数必须跟router配置的url对应,如果参数值为空字符串或url连接多出参数,错误提示 not found 。能否输出正确的对象? 比如 /list/:id 输出 {id:''} ,多个参数如何配置url呢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.