我是 QML 的新手。根据位于 http://doc.qt.nokia.com/4.7-snapshot/qdeclarativescope.html 的 QML 文档,Text 对象应该显示 15,但它只输出 5。谁能帮帮我?
Text {
id: counter
x: 300;
y: 300;
property int a: 5;
function randNumber(a){
var a = a+10;
return a;
}
text: a;
}
最佳答案
函数中的 a
是函数的局部变量,因为您在它前面加上了 var
。相反,让它:
function randNumber(a){
a = a+10;
return a;
}
关于javascript - QML 中的基本 Javascript/数学……为什么不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8016362/