Uncaught TypeError: Cannot read property 'map' of undefined

Uncaught TypeError: Cannot read property 'map' of undefined

如果您尝试以下代码,现在会出错,该代码已发布在官方网站上。 错误原因是什么?

http://mithril.js.org/mithril.component.html#nesting-components

var App = {
    ctrl: function() {
        return {data: [1, 2, 3]}
    },
    view: function(ctrl) {
        return m(".app", [
            //pressing the button reverses the list
            m("button[type=button]", {onclick: function() {ctrl.data.reverse()}}, "My App"),

            ctrl.data.map(function(item) {
                //the key ensures the components aren't recreated from scratch, if they merely exchanged places
                return m.component(MyComponent, {message: "Hello " + item, key: item})
            })
        ])
    }
}

var MyComponent = {
    controller: function(args) {
        return {greeting: args.message}
    },
    view: function(ctrl) {
        return m("h2", ctrl.greeting)
    }
}

m.mount(document.body, App)

哈哈,哇。文档中有很多错别字;总能找到新的 xD

App应该有一个controller,而不是ctrl

var App = {
  controller: function() {
      return {data: [1, 2, 3]}
  },