运行离子服务时输入错误

时间:2016-11-01 07:20:20

标签: cordova ionic-framework npm

There was an error serving your Ionic application: 

    TypeError: Cannot read property 'hasOwnProperty' of undefined
        at C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\utils\npmScripts.js:16:31
        at _fulfilled (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)TypeError: Cannot read property 'hasOwnProperty' of undefined
        at C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\utils\npmScripts.js:16:31
        at _fulfilled (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)
        at self.promiseDispatch.done (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:816:30)
        at Promise.promise.promiseDispatch (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:749:13)
        at C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:557:44
        at flush (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:108:17)
        at nextTickCallbackWith0Args (node.js:452:9)
        at process._tickCallback (node.js:381:13)

1 个答案:

答案 0 :(得分:0)

需要一些代码。通常,这可能表明您在设备准备好之前尝试做某事。像这样构建你的代码:

document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
    function onDeviceReady() {
        //Do your stuff
    };

通过这种方式,您确定所有内容都已加载,因此空引用异常的可能性降低,