Backbone視圖渲染React組件

來源:互聯網
上載者:User

標籤:

 1 <!DOCTYPE html> 2 <html> 3   <head> 4     <meta charset="UTF-8" /> 5     <title></title> 6     <script src="react/react-0.14.7/build/react.js"></script> 7     <script src="react/react-0.14.7/build/react-dom.js"></script> 8     <script src="react/browser.min.js"></script> 9     <script type="text/ecmascript" src="app/scripts/vendor/jquery.min.js"></script>10       <script src="app/scripts/vendor/underscore.js"></script>11        <script src="app/scripts/vendor/backbone.js"></script>12   </head>13   <body>14     <div id="example"></div>15     <script type="text/babel">16       var HelloMessage = React.createClass({17         render: function() {18           return <h1>Hello World!{this.props.name}</h1>;19         }20       });21 22       ReactDOM.render(23         <HelloMessage />,24         document.getElementById(‘example‘)25       );26 27 28        var MyView = Backbone.View.extend({29   el: ‘body‘,30   template: ‘<div class="widget-container"></div>‘,31   render: function() {32     this.$el.html(this.template);33     var HM=React.createFactory(HelloMessage);   34     ReactDOM.render(new HM({name:‘xxxxx‘}), this.$(‘.widget-container‘).get(0));35     // ReactDOM.render( HM({name:‘xxxxx‘}), this.$(‘.widget-container‘).get(0));36     //  ReactDOM.render(<HM  name=‘xiaoxiao‘/>), this.$(‘.widget-container‘).get(0));37     //  ReactDOM.render(<HelloMessage  name=‘xiaoxiao‘/>), this.$(‘.widget-container‘).get(0));38     return this;39   }40     });41 42         new MyView().render();43     </script>44   </body>45 </html>

 

Backbone視圖渲染React組件

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.