整个项目重构模块化之后,老是出现 page is not defined ;
最后发现,是俩个js文件的引入顺序错了。
在模块化之前,是能够跑通的,上代码
这是我封装的分页的插件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- 引入的分页插件的css -->
<link rel="stylesheet" href='../../css/commencss/fenye.css'>
</head>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
.box {
width: 800px;
margin: 10px auto;
overflow: hidden;
}
ul li {
width: 200px;
height: 300px;
margin-left: 10px;
float: left;
}
ul li img {
display: block;
width: 200px;
height: 200px;
}
ul li p {
font-size: 14px;
}
button {
width: 100%;
height: 30px;
line-height: 30px;
margin-top: 10px;
text-align: center;
}
</style>
<body>
<div class="box">
<ul id='content'>
</ul>
</div>
<div id="page" class='page'>
</div>
</body>
<!-- 处理数据的js -->
<script src='../../js/user/goodslist.js' type='module'></script>
<!-- 引入的分页插件的js -->
<script scr='../../js/commenjs/fenye.js'> </script>
</script>
</html>
运行以后