示例
const dict = require('../models/dictionary/')
const model = req.query.model
var query = dict.model.find({}) //doesn't work
var query = dict.AutoDict.find({}) //works
怎么做,代码var query = dict.model.find({})
开始工作了?
答案 0 :(得分:0)
如果要使用变量到达对象字段,则需要在括号内引用它:
var query = dict[model].find({})