【问题标题】:Simple button not showing简单按钮不显示
【发布时间】:2016-02-26 00:16:03
【问题描述】:

我正在尝试使用 Meteor 1.2.1 起步,但失败得很惨。

我只是使用了来自this question 的代码,但总是收到一个空白页。如果我删除 Button 类,让 div 出现或在其中显示文本没有问题。

我没有收到任何控制台错误。

我添加的包:

  • twbs:bootstrap 3.3.6
  • universe:react-bootstrap 0.24.0
  • 反应 0.14.3*

代码:

if (Meteor.isClient) {

Meteor.startup(function () {
    let App=React.createClass({

        render: function () {
            return (
                <div>
                      <Button>Default</Button>
                </div>
            );
        }

    });
    React.render(<App/>, document.getElementById("container"));
});

}

我希望我所缺少的一切都非常简单,但除了 reac-bootstrap 是原因之外,无法缩小范围。

【问题讨论】:

    标签: meteor react-bootstrap


    【解决方案1】:

    您是否在代码中的任何位置 require/import Button 组件?也许这就是缺少的东西。

    【讨论】:

    • 你走在正确的轨道上。在应用程序的 .jsx 中,我必须包含 let { Button } = ReactBootstrap;,否则它是 *.import.jsx 文件中的 import { Button } from 'bootstrap';(根据 Universe:documentation.go figure)
    【解决方案2】:

    在我的无知中,我根本没有关注universe:react-bootstrap documentation

    作为一个全球性的

    这个包另外将 ReactBootstrap 导出为全局,所以你 可以在任何 .jsx 文件中写入:

    let { Button } = ReactBootstrap;

    &lt;Button /&gt; // React component

    &lt;ReactBootstrap.Button /&gt; // React component

    let { Button } = ReactBootstrap;
    
    if (Meteor.isClient) {
    
        Meteor.startup(function () {
    
            let App=React.createClass({
    
                render: function () {
                    return (
                      <div>
                          <Button>Default</Button>
                      </div>
                    );
                }
    
            });
            React.render(<App/>, document.getElementById("container"));
        });
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-12-16
      • 2016-11-24
      • 1970-01-01
      • 2022-01-05
      相关资源
      最近更新 更多