[英]Uncaught SyntaxError: Unexpected token . when using ClassNotty
I'm attempting to implement this example found here : ClassyNotty , I've imported the necessary references for the css and js. 我正在尝试实现以下示例: ClassyNotty ,我已经为css和js导入了必要的引用。
If I do $.ClassNotty in the chrome console the js script is accessible, any idea? 如果我在chrome控制台中执行$ .ClassNotty,则可以访问js脚本,知道吗?
<h:head>
<script src="#{request.contextPath}/resources/js/jquery.classynotty.min.js"></script>
<link rel="stylesheet" href="#{request.contextPath}/resources/css/jquery.classynotty.min.css"></link>
</h:head>
<div>
<a id="sample1" href="#">Messages!</a>
<script>
$(document).ready(function(){
$("#sample1").click({
$.ClassyNotty({
title : 'Title',
content : 'This is a notification'
});
});
});
</script>
</div>
The error is because the .click()
argument is an Object literal, {...}
, which expects to contain key: value
pairs rather than statements like $.ClassyNotty(...)
. 该错误是因为
.click()
参数是对象文字{...}
,它期望包含key: value
对,而不是$.ClassyNotty(...)
类的语句。
$("#sample1").click({
$.ClassyNotty({ /* ... */ });
// ^ the parser expected a `:` here to separate a key and value
});
The argument to .click()
should be a function
instead, which does allow statements. .click()
的参数应改为一个function
,该函数允许语句。
$("#sample1").click(function () {
$.ClassyNotty({ /* ... */ });
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.