.js文件中的JQuery语法错误,我的脚本标签错了吗?

问题描述 投票:-3回答:1
<script>
    let sectionFlags = {
        objective: true; // '} expected'
        coursework: true;
        education: true;
        technicalSkills:true;
    }
    function toggleSection(id){
        sectionFlags[id] { //'} expected'
        if(sectionFlags[id]){
            $('#' + id.css('display','block'));
        }
        else {
            'none'; //'} expected'
        }
      }
    }
    let resume;
    function displayObjective() {
        $('#objective').html(htmlFrag);
  }
function displayFromJson() {
    displayObjective(); //'} expected'
    $("#objectiveHeading").on('click', {id: 'objective'}, toggleSection) // '} expected'
}
$(document).ready(function(){
    $.getJSON('resume.json'), function(resumeData) {
        resume = resumeData;
        displayFromJson();
    });
});
</script>
<script type = "text\javascript" src = 
    "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
</script>
<script src ='resume.html'></script> // 'JSX expressions must have one parent element'

我有这个.js文件的问题。我应该使用cdn加载jquery,我读过的所有资源都是在文件末尾的script标签中完成的。经过更多搜索后,我意识到我需要在标签中包含“text \ javascript”作为类型,但这并没有解决我的任何错误。据我所知,从我的搜索中我正确加载它。

我得到的错误是'}预期'和'JSX表达式必须有一个父元素'。我已经评论了这些错误的位置。任何帮助将不胜感激,据我所知,有没有缺少括号...我没有得到任何研究我正在做的事情。提前致谢!!

javascript jquery cdn src
1个回答
1
投票

尝试将这些分号更改为逗号。

let sectionFlags = {
    objective: true,
    coursework: true,
    education: true,
    technicalSkills:true
};
© www.soinside.com 2019 - 2024. All rights reserved.