在代码中查看 console.log 事件输出的最简单、最清晰的方法是什么。我正在创建一个 sqlite 数据库,并想简单地发出警报或 console.log 来测试它是否存在。例如,如果我这样做:
function onDeviceReady() {
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 5000);
db.transaction(populateDB, errorCB, successCB);
if(db)
{
console.log("DB created");
alert('The database is working');
}
else
{
alert('There is a problem');
}
}
我没有得到任何警报。做错了什么?
我现在有了基于此的代码:deviceReady not working in PhoneGap application,怎么办?
<body onload="onDeviceReady()">
function init(){
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is ready
//
function onDeviceReady() {
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 5000);
if(db) {
console.log('The database is working');
db.transaction(populateDB, errorCB, successCB); // only do stuff if db exists
}
else{
console.log('There is a problem');
}
}
但仍然没有日志!