【问题标题】:Material UI / material-ui appbar leftnav toggle not workingMaterial UI / material-ui appbar leftnav 切换不起作用
【发布时间】:2015-09-26 23:32:20
【问题描述】:

我正在使用meteor react-packages,并且我的appbar正确显示,但我无法让导航切换工作。我直接使用示例中的代码,我什至阅读了 material-ui repo 中的代码,它似乎应该可以工作。我做错了什么?

let {AppBar, LeftNav} = mui

AppLayout = React.createClass({
  menuItems: [
    {route: '/profile/bio', text: 'bio'},
    {route: '/profile/photos', text: 'photos'},
    {route: '/profile/videos', text: 'videos'},
    {route: '/profile/filmography', text: 'filmography'},
    {route: '/profile/settings', text: 'settings'},
    {route: '/profile/accounts', text: 'accounts'}
  ],

  _toggle(e){
    e.preventDefault()
    this.refs.leftNav.toggle()
  },

  render(){
    return (
      <div>
        <AppBar onLeftIconButtonTouchTap={this._toggle} title='react+meteor'  />
        <LeftNav ref="leftNav" docked={false} menuItems={this.menuItems} />
        <AppView />
      </div>
   )
  }
})

【问题讨论】:

    标签: javascript meteor reactjs material-design material-ui


    【解决方案1】:

    请按照此处的指南进行操作:http://react-in-meteor.readthedocs.org/en/latest/client-npm/

    我在这里错过了 mui 指南的一部分:http://material-ui.com/#/get-started

    这是我的lib/app.browserify.js 文件:

    // material ui
    mui = require('material-ui')
    injectTapEventPlugin = require("react-tap-event-plugin")
    // Needed for onTouchTap
    // Can go away when react 1.0 release
    // Check this repo:
    // https://github.com/zilverline/react-tap-event-plugin
    injectTapEventPlugin()
    
    // this is needed for material-ui styling to work properly
    ThemeManager = new mui.Styles.ThemeManager()
    React.initializeTouchEvents(true)
    

    我错过了这行injectTapEventPlugin(),它实际上是进行注射的!在我添加并刷新浏览器后,菜单完美运行。

    【讨论】:

      猜你喜欢
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2018-12-02
      • 2020-09-26
      • 1970-01-01
      相关资源
      最近更新 更多