Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

早上好 #5

Closed
wuxinzhe opened this issue Aug 24, 2017 · 6 comments
Closed

早上好 #5

wuxinzhe opened this issue Aug 24, 2017 · 6 comments

Comments

@wuxinzhe
Copy link

我看到,directive文件夹里的js文件都会定义一个priority,优先权这个属性,我想知道,这个属性的意义是什么?

@hmhao
Copy link
Owner

hmhao commented Aug 25, 2017

由于开发者在模板上书写directive的顺序是随机的,但某些directive间是有依赖关系或必须优先执行,所以会依据priority排序来执行directive。

例如if优先级较高,决定了后面要不要继续执行其他directive

这个priority你可以参考avalon源码里面的directive是怎样使用的

@wuxinzhe
Copy link
Author

还有我发现一个情况,不知道是不是bug。我在win7的虚拟机中,down下了项目,build以后,用nginx做了映射后,ie8打开一片空白,也不报错。用开发dev命令启动,依然一片空白,但是当我打开开发者工具再刷新,页面就正常加载了,这个是啥原因?

@hmhao
Copy link
Owner

hmhao commented Aug 25, 2017

这个是因为ie8-没有console,我看了一下是eventsource-polyfill这个引起的。
broswerify-eventsource.js里面改一下就好

if (window.console){
	console.log("polyfill-eventsource added missing EventSource to window");
}

eventsource-polyfill只有在dev下用到

至于build后显示空白是因为你没有修改config/index.js配置中的assetsPublicPath,这个决定了拉取资源的相对路径,项目由于是发布到github上,所以

assetsPublicPath: '/avalon2-webpack2-spa/'

你本地的话改成这样就行了

assetsPublicPath: '/'

@wuxinzhe
Copy link
Author

你好~周末快乐。

我在实践框架的时候,遇到了一点问题,想跟你询问一下。

就是路由跳转的api是哪个方法?我看了mmRouter的文档,里面只写了一个avalon.router.navigator()但这个方法发现虽然页面跳转了,可是地址栏并没有改变,我想问,是有其他更合适的方法么?

@hmhao
Copy link
Owner

hmhao commented Aug 26, 2017

使用avalon.router.navigate的第二个参数

    /*
     *  @interface avalon.router.navigate 设置历史(改变URL)
     *  @param hash 访问的url hash   
     */
    navigate: function (hash, mode) {
        ...
        // 模式0, 不改变URL, 不产生历史实体, 执行回调
        // 模式1, 改变URL, 不产生历史实体,   执行回调
        // 模式2, 改变URL, 产生历史实体,    执行回调
        if (mode === 1) {
            avalon.history.setHash(hash, true)
        } else if (mode === 2) {
            avalon.history.setHash(hash)
        }
        ...
    }

@wuxinzhe
Copy link
Author

3Q~

@hmhao hmhao closed this as completed Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants