qml TypeError: Cannot read property 'xxx' of undefined 错误处理

来源:互联网 发布:宝山行知幼稚园 编辑:程序博客网 时间:2024/04/29 20:55

qml判断变量为 undefined类型:


import QtQuick 2.5import QtQuick.Window 2.2Window {    visible: true    width: 640    height: 480    title: qsTr("Hello World")    function checkData(data){    }    MouseArea {        anchors.fill: parent        onClicked: {            var data;            console.log("check data is undefined ? \n",                        data === undefined,              "data === undefine,         \n", // true                        typeof(data) === "undefined",    "typeof(data) === \"undefine\"\n" // true                        )//            Qt.quit();        }    }    Text {        text: qsTr("Hello World")        anchors.centerIn: parent    }}


        }

1 0
原创粉丝点击