js异步写:通过callback回调函数
function SelectData(sql,callback) {
var items;
db.transaction(function (context) {
context.executeSql(sql, [], function (context, results) {
items = results.rows;
});
}, function (error) {
console.log('查询数据失败:[' + error.message + ']');
callback(items);
}, function () {
console.log('查询数据成功');
callback(items);
});
}

var sql=' 'SELECT * FROM Student';
SelectData(sql,function(data){
console.log(data)
})


墨子鱼
16 声望1 粉丝