mobx 4.x 版本和 5.x 版本区别较大。老师讲的是 4.x,你应该是安装了 5.x,由于5.x使用了 Proxy 对象来实现 observable ,所以会有差异
https://github.com/mobxjs/mobx/blob/master/src/types/observablearray.ts#L506
export function isObservableArray(thing): thing is IObservableArray<any> { return isObject(thing) && isObservableArrayAdministration(thing[$mobx]) }
const isObservableArrayAdministration = createInstanceofPredicate( "ObservableArrayAdministration", ObservableArrayAdministration )
export function createInstanceofPredicate<T>( name: string, clazz: new (...args: any[]) => T ): (x: any) => x is T { const propName = "isMobX" + name clazz.prototype[propName] = true return function(x) { return isObject(x) && x[propName] === true } as any }
https://github.com/liouswll
是的,我的问题也解决了