dva-example-user-dashboard icon indicating copy to clipboard operation
dva-example-user-dashboard copied to clipboard

fix app.model: namespace should be unique

Open adam1985 opened this issue 9 years ago β€’ 3 comments

adam1985 avatar Mar 17 '17 05:03 adam1985

δΈΊε•₯θΏ™δΉˆζ”Ή?

sorrycc avatar Mar 21 '17 02:03 sorrycc

εΊ”θ―₯ζ”ΉδΈΊθΏ™ζ ·οΌš

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

MinJieLiu avatar Aug 09 '17 06:08 MinJieLiu

πŸ‘

sorrycc avatar Aug 11 '17 12:08 sorrycc