todo.find() .exec(function(err, todos){ todos[0].test = 1; console.log(todos[0].test);//打印结果不是1 res.render('index', function(){ todos : todos }) })
测试过当test为data类型或为objectID类型是对其赋值不生效,当其为String类型时赋值生效!为什么呢?
回复 (1)
C
todos[0].test = 1; //不是所有的类型都可以这样赋值,具体是怎么情况我要去看看文档才能告诉你啊 console.log(typeof(todos[0])); //看看是什么类型 console.log(todos[0].test);//打印结果不是1
参与回复
登录后即可参与回复。登录