在页面上加载项目时出现 Javascript 错误

标签 javascript jquery

我的网站有两个错误,我认为问题在于 javascript。我有显示这两个错误和代码的 Firebug 插件,但我不知道如何修复它。

语法错误:参数列表后缺少 )

window.Templates['home'] = _.template('<% if (loggedInUser == null){ %><% } %><div id="home_container">  <div id="home_title">--- is back!</div>  <div id="home_description">Created by music lovers, for music lovers.</div>  <div id="home_header">    <div class="home_header home_header_on"><a href="/explore">Search</a><span> all your favorites</span></div>    <div class="home_header"><a href="#">Share</a><span> songs with friends</span></div>    <div class="home_header"><a href="/trending">See </a> <span>What's </span> <span>Trending</span></div>  </div>  <div id="home_description"> --- is the best way to find and share music online</div>   <div id="home_search_container">    <form id="home_search_form">      <input id="home_search" class="large_input_text" placeholder="Search music" type="text" />      <input id="home_search_button" type="button" value="search" />      <span id="home_search_bg"></span>    </form>  </div>  <div id="home_share" class="hidden">    <div id="home_share_wrapper"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="lala" data-related="----:The best place for music on the web">Tweet</a>      <div id="fb-root"></div>      <div class="fb-like" data-send="false" data-layout="button_count" data-width="95" data-show-faces="true"></div>      <g:plusone size="medium"></g:plusone>    </div>  </div>  <div class="clear"></div></div><div id="home_footer_container"></div><body background="http://www.----.com/assets/images/testbg.jpg">');

另一个错误是箭头指向的地方 ReferenceError: 模板未定义

var SongView = Backbone.View.extend({
    showAvatar: true,
    user: null,
 ->   template: Templates.common_songs,
    tagName: "div",
    className: "song_row a_song",
    events: {
        "click .song_view_love": "onLovedClicked",
        "click .song_view_share": "onShareClicked",
        "click .song_view_play_button": "onPlayButtonClicked",
        "click .song_view_queue": "onQueueClicked"
    }

这是固定的。然而,修复 window.Templates js 导致了新的(类型错误:be 未定义),如下所示。有什么想法吗?

Zc.prototype.Ga=function(a){var b=a[0],c=window;c.google_unique_id?++c.google_unique_id:c.google_unique_id=1;b.cb=c.google_unique_id;this.f.U&&(P(this,"hxva",1),O(this,"cmsid",this.f.H),O(this,"vid",this.f.I));isNaN(this.f.Da)||P(this,"pod",this.f.Da);isNaN(this.f.Ea)||P(this,"ppos",this.f.Ea);isNaN(this.f.r)||P(this,"scor",this.f.r);N.prototype.Ga.call(this,a);a=window;var b=a.document.domain,d=a.document.cookie,e=a.history.length,f=a.screen,g=a.document.referrer,k=Math.round((new Date).getTime()/

最佳答案

在你的第一个例子中你有一个'

window.Templates['home'] = _.template('<% i<snip>...span>What's
                                                             ^

这是终止 _.template(' 中的字符串,从 What's 中删除 ' 并尝试

关于在页面上加载项目时出现 Javascript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18877446/

相关文章:

javascript - 单击 mat-button 隐藏一个组件并显示其他一个 Angular 9

javascript - 在内容框中制作 bs4 导航栏

php - 在单段代码中混合 PHP、Javascript、Ajax

javascript - 下拉菜单的 onclick 方法在 Chrome 中不起作用?

javascript - 如何实现带分页的目录

javascript - 如何在 map 函数中为每个 ID 获取项目

javascript - 如何在一页上获得多个 slider ?

javascript - ReactJS - this.functionname 不是函数

javascript - 检查 jQuery 中是否为 undefined 和 null

jquery - 复选框选择上的文本删除线