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

使用avalon.mobile.js时router会报错 #45

Open
tower1229 opened this issue Jan 28, 2015 · 4 comments
Open

使用avalon.mobile.js时router会报错 #45

tower1229 opened this issue Jan 28, 2015 · 4 comments

Comments

@tower1229
Copy link

mmRouter示例页面(https://github.com/RubyLouvre/mmRouter/blob/master/index2.html )默认使用的是avalon.js也就是全兼容版本的avalon,路由功能都正常,但是只要换上avalon.mobile.js就会报错。
我用的chrome40,avalon.mobile版本是1.391,控制台报错:“warning: home状态对象的【】视图对象 必须存在template, templateUrl, templateProvider中的一个”。

@tower1229
Copy link
Author

没有人维护?

@RubyLouvre
Copy link
Owner

听同事说是修好了,你给一些复现步骤

@tower1229
Copy link
Author

好吧,代码刚贴到avalon那边了,再贴一遍,进入框架页面后点二级链接在ie11和android4.0都不触发路由:

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<title>pptViewer</title>
<link href="css/style.css" rel="stylesheet" />
<script src="lib/avalon.mobile.min.js"></script>
<script>
require(["ready!", "mmState", "mmRequest.modern"], function() {
    //顶层VM
    avalon.define({
        $id:"app",
        islogin:true,
    });
    // 路由
    avalon.state("ppt",{
        controller:"app",
        url:"/ppt",
        onChange:function(){
            if(!avalon.vmodels.ppt) {
                alert("获取初始数据,马上进入下一层")
                var model = avalon.define({
                    $id:"ppt",
                    currentChannelName :"",
                    ppt :[]
                })
                setTimeout(function(){
                    avalon.router.navigate('/ppt/hot');
                },0)
            };
        },
        views:{
            "":{
                template : "<div>框架界面<div ms-view></div></div>"
            }
        },
        onAfterLoad:function(){

        }
    })

    avalon.state("ppt.list",{
        controller:"ppt",
        url:"/{type}",
        onChange:function(type){
            alert(type);
            if(!avalon.vmodels.ppt) {
                avalon.router.navigate("/ppt");
                return;
            };
        },
        views:{
            "":{
                template:"<p> <a href='#!/ppt/hot'>热门</a> <a href='#!/ppt/all'>全部</a> <a href='#!/ppt/mine'>我的</a></p>"
            }
        }
    })

    avalon.history.start();

    avalon.scan();

})
</script>
</head>
<body ms-controller="app">
    <div ms-view><a href="#!/ppt">点击</a></div>
</body>
</html>

@gogoyqj
Copy link
Contributor

gogoyqj commented Mar 3, 2015

更新一下js看看,我这边试好像是mobile.js require的路径算不对啊

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

3 participants