{"action":"opened","issue":{"url":"https://api.github.com/repos/RubyLouvre/avalon2/issues/81","repository_url":"https://api.github.com/repos/RubyLouvre/avalon2","labels_url":"https://api.github.com/repos/RubyLouvre/avalon2/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/RubyLouvre/avalon2/issues/81/comments","events_url":"https://api.github.com/repos/RubyLouvre/avalon2/issues/81/events","html_url":"https://github.com/RubyLouvre/avalon2/issues/81","id":176338273,"number":81,"title":"avalon2-单页面问题","user":{"login":"chenliangyucd","id":21289157,"avatar_url":"https://avatars.githubusercontent.com/u/21289157?v=3","gravatar_id":"","url":"https://api.github.com/users/chenliangyucd","html_url":"https://github.com/chenliangyucd","followers_url":"https://api.github.com/users/chenliangyucd/followers","following_url":"https://api.github.com/users/chenliangyucd/following{/other_user}","gists_url":"https://api.github.com/users/chenliangyucd/gists{/gist_id}","starred_url":"https://api.github.com/users/chenliangyucd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenliangyucd/subscriptions","organizations_url":"https://api.github.com/users/chenliangyucd/orgs","repos_url":"https://api.github.com/users/chenliangyucd/repos","events_url":"https://api.github.com/users/chenliangyucd/events{/privacy}","received_events_url":"https://api.github.com/users/chenliangyucd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-12T10:03:39Z","updated_at":"2016-09-12T10:03:39Z","closed_at":null,"body":"每次切换路由的时候需要加载页面模板，，和所对应的页面JS采用require.js,发现每个页面自己js通过avalon.define()定义的。。第一次渲染正常，下一次会报错error:[' + $id + '] had defined，代码如下\r\ndefine([\"avalon\"],function(avalon){\r\n\treturn function(container,menu,param){\r\n             var canSubMenus = avalon.define({\r\n\t\t$id:\"can_subMenus\",\r\n\t\tmenu:{}\r\n\t    });\r\n            avalon.scan(container);\r\n       };\r\n});\r\n如果把avalon.define写在外面。。。不是每次定义发现第一次正常。。第二次不会渲染,看了下代码发现\r\nvm && !vm.$element 这个限制。。vm依然存在于avalon.vmodels。上一次已经初始化好了，所以不会重新渲染。\r\ndefine([\"avalon\"],function(avalon){\r\n  var canSubMenus = avalon.define({\r\n\t\t$id:\"can_subMenus\",\r\n\t\tmenu:{}\r\n\t   });\r\n\treturn function(container,menu,param){\r\n               avalon.scan(container);\r\n        };\r\n});\r\n1.当页面重新进来的时候，如何让这个VM重新渲染一遍?\r\n2.当ms-controlll对应的真个元素移除的时候，其对应的VM有没有办法消除?\r\n3.目前本人这么处理的delete avalon.vmodels[$id]，感觉太简单粗暴了有没有更好的办法。\r\n4.avalon2这个框架。。适合单页面应用吗？"}}
{"actor":{"display_login":"chenliangyucd"}}