前端Header、Footer模块化加载 + webStorm秘钥
问题描述
在非模块化开发下,前端静态页面,重复使用header/footer代码,一旦需要修改,就变得很麻烦,需要一一修改;如何实现多个.html静态页,引用同一个header.html和footer.html文件?
解决方案
1 . 前端模块化工具glup,不详细解释
2 . Jquery中的Ajax.load,异步加载事件,推荐使用
具体操作
1 . 引入Jquery.min.js
2 . 新建2个.html文件,分别命名为:header.html(只保留header部分) 、footer.html(只保留footer部分)
3 . 页面中通过script引入
切记: header.html和footer.html中,只保留各自代码,其余html、body等标签通通干掉
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo演示</title>
</head>
<body>
<!-- 顶部导航 -->
<div class="headerpage"></div>
<!--中部主体-->
<p>···代码省略···</p>
<!--footer-->
<div class="footerpage"></div>
<script src="js/jquery.min.js"></script>
<script>
$(function(){
$(".headerpage").load("header.html");
$(".footerpage").load("footer.html");
});
</script>
</body>
</html>
webStorm激活秘钥
1 . 选择中间的activetion code
2 . 输入一下代码 ↓ ↓ ↓ ↓ ↓
2RRJMBXW33-eyJsaWNlbnNlSWQiOiIyUlJKTUJYVzMzIiwibGljZW5zZWVOYW1lIjoi5b285bK4IHNvZnR3YXJlMiIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDE5LTA3LTA3In0seyJjb2RlIjoiUlMwIiwicGFpZFVwVG8iOiIyMDE5LTA3LTA3In0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMTktMDctMDcifSx7ImNvZGUiOiJSRCIsInBhaWRVcFRvIjoiMjAxOS0wNy0wNyJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDE5LTA3LTA3In0seyJjb2Rl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