我的notify.js出现以下错误:
未捕获的ReferenceError:未定义通知
这是我的js中的代码
function onPermissionGranted() {
doNotification("Notification Allowed", "You will now receive notifications once your checking is complete.")
}
function onPermissionDenied() {
console.warn("Permission has been denied by the user")
}
function doNotification(t, e) {
new Notify(t,{
body: e
}).show()
}
window.onbeforeunload = function() {
if ("" != $("#live").val() || "" != $("#cclist").val())
return "You're about to leave this page. Are you done saving your live results?"
}
,
Notify.needsPermission && Notify.requestPermission(onPermissionGranted, onPermissionDenied);
var timer, list, tlist, tw = 191, stop = !0, ct = 0, akey = "10001|BB21C00153BEEE1A0419ED806D47E63E9054CA1CAA0DEF2DBC4FEB9365992243F33707C0EEC6B3643EB77D41D6BF48F2F015C83CCAE6CC7D1C54D3ECEAC45E00A443AFFD8E2642EAB3A68BCE0841E7FB3EC257D51BBA3A35FD378D551E5F08BDB55F9CDBCF7F363E1857D85B0B62760294FFC8395ECEC42C9BC3EDC71E06FA7D188C594F1D17D4392308F1123CAA89DF1099EF729DA723654FBEFCD9884885DD3EEED42E97C462788D685587518FB62883AF0739594D67C42F77466A276D34AD1461FA60DCB0A5A2AFC9A02F4E800CA9DB2AC5C010697CF0F0479E9710F849A052E949DC9082E7A67E43A9BF722354AB3616F1C4ECACD616950CCED7702C5A17";
运行页面时出现控制台错误。
答案 0 :(得分:0)
您的Notify
类很可能在另一个文件中,而在该文件中未引用此错误。
错误
未捕获的ReferenceError: [ref] 未定义
是一个错误,告诉您您的代码具有JavaScript解释器无法理解的引用,并且它不能...很好...对其进行解释。 [ref]
是触发错误的引用的名称。它可以是未知类,未定义变量或未定义函数。检查拼写错误,并确保已声明和包含了该类。
此外,请确保在使用该脚本的脚本之前 导入了您的类的导入的JavaScript文件:
<script src="path/notify.js" type="text/javascript" />
<script src="path/usingnotify.js" type="text/javascript" />
可以工作,而
<script src="path/usingnotify.js" type="text/javascript" />
<script src="path/notify.js" type="text/javascript" />
不会。