Files
ClassContent/历届学生/fontendseven/项目练习/个人练习/蔡敏/屁桃儿/js/utils/utils.js
2024-09-27 02:06:13 +08:00

44 lines
1.3 KiB
JavaScript

class Utils {
footer() {
var footerArr = [
{ title: '首页', icon: 'icon-home', href: 'index.html' },
{ title: '机构', icon: 'icon-jigou', href: 'mechanism.html' },
{ title: '模特', icon: 'icon-me', href: 'model.html' },
{ title: '我的', icon: 'icon-wo', href: 'my.html' },
];
// 用户当前正在访问的页面地址
// http://localhost:63342/page/mechanism.html
var currentPath = location.href;
$("body").innerHTML += `
<ul class="footer">
${
footerArr.map((v,index) => {
return `
<li class="${currentPath.includes(v.href) ? 'footer_active' : ''}">
<a href="./${v.href}">
<i class="iconfont ${v.icon}"></i>
<p>${v.title}</p>
</a>
</li>
`
}) .toString().replaceAll(",", "")
}
</ul>
`
}
$(className) {
return document.querySelector(className);
}
_(className) {
return document.querySelectorAll(className);
}
}
// 对象的解构赋值
var { footer, $, _ } = new Utils()
// var utils = new Utils()