Ano*_*non 4 programming syntax application-development qml ubuntu-sdk
例如:
Item {
id: sylvainLikesAnsweringMyQuestions
property var myDict: {[key,value],[anotherKey,anotherValue]}
}
Run Code Online (Sandbox Code Playgroud)
在 JavaScript/QML 中,对象是具有属性和方法的数据(变量)。您还可以创建自己的对象。
此示例创建一个名为“results”的对象,并向其添加四个属性:
property var results: {"passed": 15, "failed": 2, "skipped": 1, "IlikeYourQuestions": 1};
Run Code Online (Sandbox Code Playgroud)
您还可以向其中添加方法,但只需一组属性,它的工作方式与字典完全相同。
您可以通过两种方式访问对象属性:
results.passed;
results["passed"];
Run Code Online (Sandbox Code Playgroud)
资料来源: http: //www.w3schools.com/js/js_objects.asp