当我尝试使用 NavigationView 的视图堆栈上推送视图时
MyApp.getPath('mainPage.mainPane.content.nav').push(MyApp.MyView);
它给了我这个:
Uncaught TypeError: Object function (props) {
      this.__sc_super__ = ret.prototype;
      return this._object_init(props);
    } has no method 'get'
显然,SC.View 不兼容 KVO。那么是不是 SproutCore 框架的 bug 呢?因为他们在 SC.NavigationView 源代码中执行此操作:
view.get("topToolbar"); // with `view` being the view I passed in as shown above
MyApp.MyView看起来像这样:
MyApp.MyView = SC.View.extend({
    childViews: 'search results'.w(),
    search: SC.TextFieldView.design({
        layout: { centerX: 0, top: 40, width: 400, height: 30 },
        hint: "Search"
    }),
    results: SC.TemplateView.design({
        templateName: 'results'
    }),
    topToolbar: SC.NavigationBarView.design({
        childViews: ['title'],
        layout: { height: 44 },
        title: SC.LabelView.design({
            controlSize: SC.LARGE_CONTROL_SIZE,
            layout: { width: 100, height: 24, centerX: 0, centerY: 0 },
            value: 'Title'
        })
    })
});
但我认为 SproutCore 开发人员比我更聪明、更有经验,所以这可能是我做的。
为什么我的SC.View子类没有get()方法?