我想在Javascript中调用一个函数,但它不工作。JavaScript不能在科尔多瓦与温泉
我没有在温泉网站和Google上找到任何参考。
任何人都可以告诉我在JavaScript中调用函数的精确步骤是什么?
我需要在index.js文件中定义函数还是可以在脚本标记中的同一个文件中写入函数?
我使用温泉2
我也曾询问过关于 JQuery但没有解决办法还没有类似的问题。
p1.html
<body onload="onLoad()">
<ons-page>
<ons-button id="demo" onclick="printMsg()">Click Me</ons-button>
</ons-page>
index.js
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.getElementById('demo').addEventListener("click", printMsg,
false);
document.getElementById('btnNext').addEventListener("click",
callNextPage, false);
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
document.addEventListener("menubutton", onMenuKeyDown, false);
}
function printMsg() {
ons.notification.alert('Hello'):
//alert('hello');
//document.addEventListener("deviceready", onDeviceReady, false);
}
输出错误消息:
“未捕获的ReferenceError:printMsg没有定义”,来源: file:///android_asset/www/index.html
编辑:
我已经上传我的项目在FileDropper
删除内联事件处理程序,以便按钮只是...'<插件按钮ID =“演示”>点击我'。这不应该解决它,但你不需要,因为你是在设备准备功能分配处理程序 – Archer
@Archer我试过它不工作 –