Open adam1985 opened 7 years ago
应该改为这样:
const registerModel = (app, model) => {
// eslint-disable-next-line no-underscore-dangle
if (!app._models.filter(m => m.namespace === model.namespace).length) {
app.model(model);
}
};
因为原有的:
const cached = {};
function registerModel(app, model) {
if (!cached[model.namespace]) {
app.model(model);
cached[model.namespace] = 1;
}
}
cached
变量在热更新之后会被清空掉。从而导致重复注入 model
👍
为啥这么改?