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

qml判断变量为 undefined类型:


 
  
import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    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
    }
}


 
  
        }

你可能感兴趣的:(qt,qml)