我有一个 Mobx 状态树模型已经长得太长了,我想将它拆分到多个 javascript 文件中。
下面是部分代码的演示:
///file1.js
import { types } from "mobx-state-tree";
export const ExampleModel = types
.model("Example", {
id: types.identifier,
name: types.optional(types.string, ""),
anotherName: types.optional(types.string, ""),
})
.views(self => ({
get test() {
return "test"
}
}))
.views(self => ({
get anotherTest() {
return "anotherTest"
}
}))
.actions(self => ({
setName(name) {
self.name = name
}
}))
.actions(self => ({
setAnotherName(name) {
self.anotherName = name
}
}))
Run Code Online (Sandbox Code Playgroud)
我想要的是将其拆分为两个文件,例如:
///file1.js
import { types } from "mobx-state-tree";
export const ExampleModel …Run Code Online (Sandbox Code Playgroud)