[英]Simple Fix, Have an Error with my Javascript
Have an issue trying to fix the errors in my Javascript syntax.尝试修复我的 Javascript 语法中的错误时遇到问题。 Sure it is something simple and I'm over-looking but it's not sinking in. Included the HTML and CSS.
当然,这很简单,我忽略了它,但它并没有陷入其中。包括 HTML 和 CSS。
Javascript Code: Javascript 代码:
const menuIcon = document.querySelector(".hamburger-menu");
const navbar = document.querySelector(".navbar");
menuIcon.AddEventListener("click", () => {
navbar.classList.toggle("change");
});
ERROR错误
line.线。 col.
上校error.
错误。
1 1. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). 1 1. 'const' 在 ES6(使用 'esversion: 6')或 Mozilla JS 扩展(使用 moz)中可用。
2 1 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). 2 1 'const' 在 ES6(使用 'esversion: 6')或 Mozilla JS 扩展(使用 moz)中可用。
4 38 'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6'). 4 38 'arrow function syntax (=>)' 仅在 ES6 中可用(使用 'esversion: 6')。
CSS CSS
/*hamburger*/
.hamburger-menu{
width:35px;
height:30px;
position:fixed;
top:60px;
right:60px;
cursor:pointer;
display:flex;
flex-direction:column;
justify-content:space-around;
}
.line{
width:100%;
height:3px;
background-color:#333;
transition:alt 0.8s;
}
.change .line-1{
transform:rotateZ(-405deg) translate(-8px,6px);
}
.change .line-2{
opacity:0;
}
.change .line-3{
transform:rotateZ(405deg) translate(-8px,-6px);
}
.nav-list{
text-align:right;
}
.nav-items{
list-style:none;
margin:25px;
}
.nav-link{
text-decoration:none;
color:#eee;
position:relative;
padding:3px 0;
}
.nav-link::before,
.nav-link::after{
content:"";
width:100%;
height:2px;
background-color:#fff;
position:absolute;
left:0;
transform:scalex(0);
transition:transform .5s;
}
.nav-link::after{
bottom:0;
}
.nav-link::before{
top:0;
}
.hav-link:hover::before,
.hav-link:hover::after{
transform:scalex(1)
}
.navbar{
width:550px;
height:132px;
background-color:#333;
position:fixed;
top:0;
right:-550px;
display:flex;
justify-content:center;
align-items:center;
border-radius:0 0 0 50px;
transition: right 0.8s cubic-bezier(1, 0, 0, 1);
}
.change{
right:0;
}
/*hamburger*/
HTML HTML
<nav class="navbar">
<div class="hamburger-menu">
<div class="line line-1"></div>
<div class="line line-2"></div>
<div class="line line-3"></div>
</div>
<ul class="nav-list">
<li class="nav-item">
<a href="about.php?page_id=46">
About</a></li>
<li class="nav-item">
<a href="portfolio.php?page_id=44">
Portfolio</a></li>
<li class="nav-item">
<a href="blog.php?page_id=530">
Blog</a></li>
<li class="nav-item">
<a href="mailto:kfrancis@kfrancisdesigns.com?Subject=Hello%20" target="_top" rel="noopener noreferrer">
Contact</a></li>
</ul>
</nav>
You can add /*jshint esversion: 6 */
ontop of your .js
files to fix this issue, as this is not a JavaScript Engine error.您可以在
.js
文件的顶部添加/*jshint esversion: 6 */
来解决此问题,因为这不是 JavaScript 引擎错误。
Furthermore, AddEventListener
is not a JavaScript function;此外,
AddEventListener
不是 JavaScript function; addEventListener
is, as pointed by TJ Crowder in a comment.正如 TJ Crowder 在评论中指出的那样,
addEventListener
是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.