1

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

SyntaxError: missing ) 在参数列表之后

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: Templates is not defined

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 会导致新的(类型错误:未定义),如下所示。有任何想法吗?

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()/
4

2 回答 2

3

在您的第一个示例中,您有一个 '

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

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

于 2013-09-18T16:28:26.137 回答
0

第二个错误是由第一个错误引起的。

如果您查看您发布的内容的末尾,语法突出显示将提供线索,因为 URL 中的“//”将其视为评论。

<body background="http://www.----.com/assets/images/testbg.jpg">');

你需要避开斜线。

于 2013-09-18T16:29:28.193 回答