【发布时间】:2016-10-14 09:44:31
【问题描述】:
我想获得一些关于尝试通过添加路由来增强我目前正在开发的网络应用程序的建议
目前我们的项目布局结构如下所示(我们有数百个这样的页面,HTML 和一个匹配的 JS 文件,可能有 1000 行代码)
html
- example1.html
- example2.html
js
-example1_functions.js
-example2_functions.js
css (Sometimes each page has there own, Majority of the time they share a few between them)
-example1_css
-example2_css
目前页面切换之间总是需要硬加载,我们的大部分页面都是使用一个主div构建的,在html中有一个ID,然后javascript会在这个div中插入内容,例如访问“mysite/example1.html” "
Html (example1.html)
------
<script src="example1_functions.js"></script>
<!-- Potentially boiler plate HTML here for filters, Headers etc -->
<div id="dataContainer"> </div>
<script>
$( document ).ready(function() {
generateContent();
});
</script>
JS (example1_functions.js)
------
function generateContent(){
document.getElementByID("dataContainer").innerHTML = "Cool content";
}
等等……
我有使用 React 路由器的经验,但我似乎无法找到有关是否可以轻松转换这样一个无法轻松表达路由的旧版 Web 应用程序的信息。
【问题讨论】:
标签: javascript html url-routing