Undefined TypeError:无法读取属性';重量';未定义的

Undefined TypeError:无法读取属性';重量';未定义的,undefined,typeerror,Undefined,Typeerror,我是新手,还在学习,我的项目是使用node.js、js、HTML制作一个体重指数计算器。。当我运行我的代码时,它在网页上运行没有问题,除非当我试图计算时,我最终出现了这个错误 我在网上看过,但我无法理解或解决我的问题。提前感谢您的帮助 MINGW32 ~/Desktop/Calculator $ nodemon calculator.js [nodemon] 2.0.4 [nodemon] to restart at any time, enter `rs` [nodemon] watchin

我是新手,还在学习,我的项目是使用node.js、js、HTML制作一个体重指数计算器。。当我运行我的代码时,它在网页上运行没有问题,除非当我试图计算时,我最终出现了这个错误

我在网上看过,但我无法理解或解决我的问题。提前感谢您的帮助

 MINGW32 ~/Desktop/Calculator
$ nodemon calculator.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node calculator.js`
calc server started!!!
TypeError: Cannot read property 'weight' of undefined
    at C:\Users\pc\Desktop\Calculator\calculator.js:30:38
    at Layer.handle [as handle_request] (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\index.js:275:10)
    at expressInit (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\middleware\init.js:40:5)
    at Layer.handle [as handle_request] (C:\Users\pc\Desktop\Calculator\node_modules\express\lib\router\layer.js:95:5)
在我的calculator.js文件中

/*eslint env es6*///启用该文件的es6错误检查
/*eslint env jquery*///启用jquery函数的错误检查
/*eslint env browser*///允许您使用文档和其他标准浏览器功能
/*eslint no console:0*///允许您使用控制台(例如,记录某些内容)
//jshint版本:6
const express=要求(“express”);
const bodyParser=require(“body parser”);
常量app=express();
get(bodyParser.urlencoded({extended:true}));
//应用程序获取(“/”,函数(请求,恢复){
//res.sendFile(uu dirname+“/index.html”);
//});
//应用程序post(“/”,功能(请求,回复){
//变量n1=编号(要求主体n1);
//var n2=编号(要求主体n2);
//var结果=n1+n2;
//    
//res.send(“计算结果为”+结果);
//});
app.get(“/bmicaller”,函数(req,res){
res.sendFile(uuu dirname+“/bmicaller.html”);
});
app.post(“/bmicaller”),函数(请求,res){
var-weight=parseFloat(要求主体重量);
var height=parseFloat(要求主体高度);
var bmi=体重/(身高*身高);
res.send(“您的体重指数为”+BMI);
});
app.listen(1990年,函数(){
log(“calc服务器已启动!!!”;

}); calculator.js的内容是什么?嗨,我刚刚添加了calculator.js,可能是相关的注意
app.get(bodyParser.urlcoded({extended:true}))中的
use
vs
get