///////
recipe = new Recipe(_.pick(req.body, ['name', 'tag', 'recipe']));
await recipe.save();
});
////// 錯誤:
食譜=新食譜(_.pick(req.body,['name','tag','recipe']));^
ReferenceError: _ 未定義
uj5u.com熱心網友回復:
你必須先匯入庫,然后才能像這樣使用它
// Requiring the lodash library
const _ = require("lodash");
// The source object
var obj = {
Name: "GeeksforGeeks",
password: "gfg@1234",
username: "your_geeks"
}
// Using the _.pick() method
console.log(_.pick(obj, ['password', 'username']));
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/467543.html
標籤:javascript 节点.js mongodb 猫鼬 后端
上一篇:如何在js中獲取鍵值并相互對應?
