routing problems when building applications using umi.js+dva.js
when building a project containing dva.js according to umi.js "s documentation, a route file automatically generated by a convention route will also generate a route entry from the dva.js "s model file
related codes
pages structure
+pages
-index.js
-model.js
automatically generated routes
routes: [
{ path: "/", component: "./pages/index.js" },
{ path: "/model", component: "./pages/model.js" }
]
as described in the document, model automatically registers by name when using dva.js. The rules are as follows:
When
src/models/**/*.js
is global modelsrc/pages/**/models/**/*.js
is page model- global model full load, page model load on demand on production, full load on development
- page model is the file
models/**/*.js
under the path where page js resides- page model looks up. For example, page js is
pages/a/b.js
, his page model ispages/a/b/models/**/*.js
+pages/a/models/**/*.js
, and so on- stipulates that model.js is a single file model, to solve the problem that you do not need to build a models directory when there is only one model, and do not look for
models/**/*.js
if you have model.js.
is registered as a model, it should not be built to use this mechanism in the routing, ant admin, and the model.js
file or the file under the / models
path is not built as a route, so it"s confusing here.