index.html:29 Uncaught SyntaxError:意外的标识符

//尝试创建时钟neo样式,css和html一切正常,除了chrome提示错误“ Uncaught SyntaxError:Unexpected identifier”!

<script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector("#hr");
        const mn = document.querySelector("#mn");
        const sc = document.querySelector("#sc");

        setInterval(() => {
            Let day = new Date();
            Let hh = day.getHours() * 30;
            Let mm = day.getMinutes() * deg;
            Let ss = day.getSeconds() * deg;

            hr.style.transform = 'rotateZ(${(hh)+(mm/12)}deg)`;
            hr.style.transform = 'rotateZ(${mm}deg)`;
            hr.style.transform = 'rotateZ(${ss}deg)`;
        })
    </script>
评论
陌影0
陌影0

let是用于在JS中声明变量的关键字,并且应小写。

If you just type Let a = 1; in your console you will see the error.

<script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector("#hr");
        const mn = document.querySelector("#mn");
        const sc = document.querySelector("#sc");

        setInterval(() => {
            let day = new Date();
            let hh = day.getHours() * 30;
            let mm = day.getMinutes() * deg;
            let ss = day.getSeconds() * deg;

            hr.style.transform = 'rotateZ(${(hh)+(mm/12)}deg)`;
            hr.style.transform = 'rotateZ(${mm}deg)`;
            hr.style.transform = 'rotateZ(${ss}deg)`;
        })
    </script>
点赞
评论