2017-08-13 28 views
0

enter image description here玩笑:類型錯誤:無法讀取的不確定

財產 '長度' 爲什麼object.anonymous

的package.json:

package.json: 
 
{ 
 
    "name": "SmartConverter", 
 
    "version": "1.0.0", 
 
    "main": "./src/js/main.js", 
 
    "scripts": { 
 
     "test": "jest --coverage", 
 
     "build": "webpack --config ./scripts/*/webpack.config.js" 
 
    }, 
 
    "repository": "https://github.com/raushankumarnitdgp/SmartConverter.git", 
 
    "author": "raushankumarnitdgp <[email protected]>", 
 
    "license": "MIT", 
 
    "dependencies": { 
 
     "babel-cli": "^6.24.1", 
 
     "babel-core": "^6.25.0", 
 
     "babel-jest": "^20.0.3", 
 
     "babel-loader": "^7.1.1", 
 
     "babel-preset-es2015": "^6.24.1", 
 
     "eslint": "^4.4.1", 
 
     "jest": "^20.0.4", 
 
     "jest-cli": "^20.0.4", 
 
     "regenerator-runtime": "^0.10.5", 
 
     "webpack": "^3.5.2" 
 
    } 
 
}

回答

1

anonymous關鍵字你在錯誤stracktrace中看到只是告訴你,這個錯誤發生在匿名函數中。匿名函數是沒有名字的函數,通常用作回調函數,但並非總是如此。例如:

function main() { 
    myLibrary.doSomething('foo', function() { 
    console.log('I have finished') 
    }) 
} 

傳遞給myLibrary.doSomething的函數是一個匿名函數。您所看到的錯誤似乎發生在phone.js文件的第20行。請檢查您使用的是.length

相關問題