yoxjs / yox-router Goto Github PK
View Code? Open in Web Editor NEWyox-router
Home Page: https://yoxjs.github.io/yox-router
License: MIT License
yox-router
Home Page: https://yoxjs.github.io/yox-router
License: MIT License
比如从/abc到/def,yox.js报错了
错误信息:Cannot read property 'off' of undefined
报错代码:
--------------------yox.js----------------------
/**
* 销毁
*/
}, {
key: 'destroy',
value: function destroy() {
var instance = this;
instance.$watchEmitter.off(); //【这里报错了】
each$1(instance, function (value, key) {
delete instance[key];
});
}
另外能不能实现vue那样的嵌套路由?
我用vue是这样布局的:
/abc
头部1
路由占位符
尾部1
/abc的子路由/def
内容1(会替换/abc的路由占位符)
/abc的子路由/ghi
内容2(会替换/abc的路由占位符)
/login
内容3(/login页面没有头部和尾部)
/opq
头部2
路由占位符
尾部2
/opq的子路由/rst
内容4(会替换/opq的路由占位符)
<!--[if IE]>
<script src="https://cdn.bootcss.com/es6-promise/4.1.1/es6-promise.auto.min.js"></script>
<![endif]-->
<!--[if lt IE 9]>
<script src="https://cdn.bootcss.com/es5-shim/4.5.13/es5-shim.min.js"></script>
<script src="https://cdn.bootcss.com/es5-shim/4.5.13/es5-sham.min.js"></script>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<!--[if lt IE 8]>
<script src="https://cdn.bootcss.com/json3/3.3.3/json3.min.js"></script>
<![endif]-->
</head>
<body>
<div id="app"></div>
<script src="./yox.js"></script>
<script src="./yox-router.js"></script>
<script>
Yox.use(YoxRouter)
var router = new YoxRouter.Router({
el: Yox.dom.find('#app'),
routes: [
{
path: '',
name: 'header_tpl',
component: {
template: ['<div class="header">', '<h1>header</h1>', '</div>'].join(
''
),
},
},
],
route404: {
path: '404',
name: '404',
component: {
template: '<div>not found</div>',
},
},
})
router.start()
</script>
</body>
路由对象1{
/abc:内容1
/def:内容2
}
路由对象2{
/abc:标题
}
先访问/abc,那么浏览器显示:
标题
内容1
再访问/def,按理说浏览器应该只显示:
内容2
但实际显示了:
标题
内容2
刷新页面后才只显示:
内容2
所以似乎没有自动清除上个组件的内容的功能。
另外一个问题,还是上面的路由配置,如果两个页面都有标题,先访问/abc,然后用浏览器审查元素的功能把“标题”,改成“标2题”,然后访问/def,标题部分又变回了“标题”,所以标题每次会重新加载。如果用vue像我上个Issue中那样用嵌套路由配置,就只会改变内容部分。
这两个问题也可能我用得不对。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.