return QML 中的 JS 中的 QT 中的值失败
return value from JS in QML from in QT fail
我正在尝试简单的功能,但没有任何功能 return 来自功能,但是“控制台日志 return 好的值,请问我的代码有什么问题吗?...
JS:
function potentieldated(Pimmatriculation, Pdateinstallation)
{
var db = dbGetHandle()
db.transaction(function (tx) {
var results = tx.executeSql(
'SELECT * FROM (SELECT * FROM (SELECT date_etape, heure_depart, heurecellule, cyclecellule from flight_log where immatriculation=? and date_etape <= ? ORDER by heure_depart desc) ORDER by date_etape desc limit 1)UNION ALL SELECT "0", "0", "0", "0" LIMIT 1 ' , [Pimmatriculation, Pdateinstallation])
var heurecellule= results.rows.item(0).heurecellule;
var cyclecellule= results.rows.item(0).cyclecellule;
console.log("heurecellule JS " + heurecellule);
console.log("cyclecellule JS "+ cyclecellule);
return {heurecellule:heurecellule,cyclecellule:cyclecellule}
})
}
QML 形式:
var potentiel= JS.potentieldated(stringVariable,dateaircraftpartinstallation)
var heure = potentiel.heurecellule
var cycle = potentiel.cyclecellule
console.log("heure "+heure)
console.log("cycle "+cycle)
console.log 留言:
qml: heurecellule JS 14010.25
qml: cyclecellule JS 4672
qrc: Cannot read property 'heurecellule' of undefined
你能帮帮我吗?
非常感谢
您没有 return 来自正确函数的值:
function potentieldated(Pimmatriculation, Pdateinstallation) {
var heurecellule = 0
var cyclecellule = 0
var db = dbGetHandle()
db.transaction(function (tx) {
var results = // ...
heurecellule = results.rows.item(0).heurecellule;
cyclecellule = results.rows.item(0).cyclecellule;
})
return {heurecellule:heurecellule,cyclecellule:cyclecellule}
}
我正在尝试简单的功能,但没有任何功能 return 来自功能,但是“控制台日志 return 好的值,请问我的代码有什么问题吗?...
JS:
function potentieldated(Pimmatriculation, Pdateinstallation)
{
var db = dbGetHandle()
db.transaction(function (tx) {
var results = tx.executeSql(
'SELECT * FROM (SELECT * FROM (SELECT date_etape, heure_depart, heurecellule, cyclecellule from flight_log where immatriculation=? and date_etape <= ? ORDER by heure_depart desc) ORDER by date_etape desc limit 1)UNION ALL SELECT "0", "0", "0", "0" LIMIT 1 ' , [Pimmatriculation, Pdateinstallation])
var heurecellule= results.rows.item(0).heurecellule;
var cyclecellule= results.rows.item(0).cyclecellule;
console.log("heurecellule JS " + heurecellule);
console.log("cyclecellule JS "+ cyclecellule);
return {heurecellule:heurecellule,cyclecellule:cyclecellule}
})
}
QML 形式:
var potentiel= JS.potentieldated(stringVariable,dateaircraftpartinstallation)
var heure = potentiel.heurecellule
var cycle = potentiel.cyclecellule
console.log("heure "+heure)
console.log("cycle "+cycle)
console.log 留言:
qml: heurecellule JS 14010.25
qml: cyclecellule JS 4672
qrc: Cannot read property 'heurecellule' of undefined
你能帮帮我吗?
非常感谢
您没有 return 来自正确函数的值:
function potentieldated(Pimmatriculation, Pdateinstallation) {
var heurecellule = 0
var cyclecellule = 0
var db = dbGetHandle()
db.transaction(function (tx) {
var results = // ...
heurecellule = results.rows.item(0).heurecellule;
cyclecellule = results.rows.item(0).cyclecellule;
})
return {heurecellule:heurecellule,cyclecellule:cyclecellule}
}