我在我的控制台上收到此JavaScript错误:
未捕获的SyntaxError:意外的标记ILLEGAL
这是我的代码:
var foo = 'bar';?Run Code Online (Sandbox Code Playgroud)
你可以看到它非常简单.怎么会导致语法错误?
Uncaught SyntaxError: Unexpected token <每当我尝试运行angular2应用程序时,我都会收到此错误.这只是基于angular2网站的路由"教程"的修改.
通常这些错误说明了我错误编写了一段代码.但是Chrome控制台告诉我在angular2 js文件中发生了错误.
阅读并试图从两者的答案Chrome Uncaught Syntax Error: Unexpected Token ILLEGAL ,并warning C4819: How to find the character that has to be saved in unicode?没有工作.猜测错误必须在我的boot.ts或app.component.ts中.
boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {AppComponent} from './app.component';
import {HallService} from './hall/hall.service';
bootstrap(AppComponent,[
ROUTER_PROVIDERS,
HallService
]);
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {HallCenterComponent} from './hall/hall-center.component';
@Component({
selector: 'my-app',
template: `
<h1 class="title">Component Router</h1>
<a …Run Code Online (Sandbox Code Playgroud) 我想知道如何用jquery淡入css类.我正在寻找的效果有点像你在这里看到的:https://squareup.com/
到目前为止我尝试过的是:
$(document).ready(function() {
$('.mini-nav li').hover(function () {
$('.hover').fadeIn(slow);
};
});
Run Code Online (Sandbox Code Playgroud)
我考虑过.addClass()方法,但我不确定在哪里添加它(或者如果这是最好的事情).
编辑:这是我试过的一个小提琴:http://jsfiddle.net/J93NR/1/
我试过这个js代码:
<script type="text/javascript">
$(document).ready( function() {
var timer;
$('.top-menu-first-ul li').hover(function(){
if(timer) {
clearTimeout(timer);
timer = null
}
timer = setTimeout(function() {
$(this).find('ul').slideToggle(100);
}, 500)
},
// mouse out
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
用这个HTML:
<ul class="top-menu-first-ul">
<li>
<a href="http://google.com">Google</a>
<ul class="top-menu-second-ul">
<li><a href="http://translate.google.com">Google Translate</a></li>
<li><a href="http://images.google.com">Google Images</a></li>
<li><a href="http://gmail.google.com">Gmail</a></li>
<li><a href="http://plus.google.com">Google Plus</a></li>
</ul>
</li>
<li>
<a href="http://facebook.com">Facebook</a>
</li>
<li>
<a href="http://twitter.com">Twitter</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我想在显示子菜单时,例如谷歌链接,其他将在300毫秒后出现.
因此,当用户快速将鼠标悬停在其上并且不会在悬停链接上停留至少300毫秒时,我需要阻止加载子菜单.
然后我需要在他离开链接时停止执行代码(或向上滑动).因为如果他经常一次又一次地翻过来然后回到一个副本,他就会停止盘旋,而代码仍在执行自己多少次将鼠标悬停在链接上.我需要以某种方式防止这种情况发生.
编辑:我需要解决这个问题没有像hoverIntent等插件,如果可能的话,只需简单的javascript和jQuery
可能重复:
webkit中的意外标记ILLEGAL
我写了一个简单的脚本悬停在效果http://jsfiddle.net/paDmg/368/这个网站http://avuedesigns.com/new/ - 它适用于jsfiddle,但我得到了
未捕获的SyntaxError:意外的标记ILLEGAL
我把它放在我的JavaScript中.它在第29行它告诉我哪个是结束标记});
$('#hover-grid .indiv-cell').hover(function() {
//set variables to current cell attributes
var cellHeader = $(this).attr('data-hoverheader');
var cellText = $(this).attr('data-hovertext');
var replacementImg = $(this).find('a img').attr('data-replacementimg');
var oringinalImg = $(this).find('a img').attr('src');
//save original image to data variable
$(this).data('origImg', oringinalImg);
//add remove classes
$('#hover-grid .indiv-cell').removeClass('newClass');
$(this).addClass('newClass', 1000);
$(this).find('a img').hide().attr('src', replacementImg).fadeIn(300);
$('.master-cell h1').hide().text(cellHeader).fadeIn(300);
$('.master-cell p').hide().text(cellText).fadeIn(300);
//return false;
}, function() {
$(this).find('a img').hide().attr('src', $(this).data('origImg')).fadeIn(10);
});?
Run Code Online (Sandbox Code Playgroud) 我不太清楚为什么我的代码会造成这种情况.
我在标题中有这个jquery脚本:
<script>
$(document).ready(function() {
$('.control').on('click', function(e) {
e.preventDefault();
var field = $(this).data('field');
$('.hider:visible').fadeOut("slow", function() {
$('#' + field + '-gallery, #' + field + '-tag').fadeIn("slow");
});
});
var randomIndex = Math.floor((Math.random() * 100) + 1) % 3;
console.log(randomIndex);
var field = $($('a').get(randomIndex)).data('field');
$('#' + field + '-gallery, #' + field + '-tag').fadeIn("slow");
})?;
</script>
Run Code Online (Sandbox Code Playgroud)
当我重新加载页面时,没有任何反应,因此脚本似乎没有运行.当我在Chrome上检查页面时,我发现这个错误位于名为(程序)的选项卡中,它位于前几行中:
if (window.top.require) {
Uncaught SyntaxError: Unexpected token ILLEGAL
window.top.require("ripple/bootstrap").inject(window, document);}
Run Code Online (Sandbox Code Playgroud)
我不知道我的代码中导致此错误的是什么.当我拿出我的剧本时,它会消失.不太确定是否是wordpress或jqueryUI的东西(我为另一个插件加载了).
javascript ×5
jquery ×3
syntax-error ×3
css ×2
html ×2
wordpress ×2
angular ×1
fadein ×1
token ×1
typescript ×1