反应组件错误

时间:2016-08-03 09:52:51

标签: angularjs reactjs

大家好2天我试图从html调用一个react组件,每次它都会给我发错误“错误:找不到反应组件MyReact” 这就是我的html。如果有人帮助我,我将非常感激

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="css/datepicker.css">
    <link rel="stylesheet" href="css/angular-material.min.css">
    <script src="react-15.3.0.js"></script>
    <script src="react-dom-15.3.0.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.js"></script>


</head>
<body ng-app="listOfDiaries" ng-controller="myCtrl as ctrl">

<react-component name="MyReact"></react-component>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular-messages.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src = 'js/bootstrap.js'></script>
<script src="js/ngReact.js"></script>
<script type="text/babel" src="tutorial.js"></script>
<script src = 'config.js'></script>

<!--data-toggle="modal" data-target="#{{myprops.id}}"-->
</body>
</html>

这是教程文件:

var MyReact = React.createClass({

    render: function() {
        console.log("qweqw");
        return(
            <div>
                <h2>georgi</h2>
            </div>
        );
    }
});
app.value('MyReact',MyReact);

和我的配置文件:

var app = angular.module('listOfDiaries', ['react','ngMaterial','ngMessages']);
app.controller('myCtrl', ["$scope", "myFirstService", function ($scope, myFirstService) {
    var self = this;
//and directive and so on..

1 个答案:

答案 0 :(得分:0)

我不编程Angular;但是查看app.directive语句中的代码;如果该代码立即运行MyReact未定义。尝试切换MyReact类和app.directive块。