我是Reactjs的新手。具体来说,我没有在项目开发中使用nodejs环境。我正在做的是: index.html 文件
<html>
<head>
<script src="https://unpkg.com/react@16/umd/react.development.js"
crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-slick/0.23.1/react-slick.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
<script type="text/babel" src="myreact.js"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>
和 myreact.js 文件:
function Favourites()
{
var settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1
};
return (<div className="rightbox">
<div className="circle-user">
<div className="ur-user">
<div className="user-inside">
<div className="hu-usercont">
<section className="hu-userct">
<div className="user-content" id="mthumb_right">
<Slider {...settings}>
<div className="usr-ct hu-it-your-profile">
<img src="img2.jpg" /><span className="user-a-name">You</span>
</div>
<div className="usr-ct hu-iot-profile" id="other_tab">
<img src="img2.jpg" /><span className="user-a-name">Others</span>
</div>
</Slider>
</div>
</section>
</div>
</div>
</div>
<div className="add-user">
<div className="add-inside">
<div className="add-usr-ct">
<div className="add-it hu-adit-profile" ><span className="hu-addur-user"><i className="fa"></i></span></div>
<span className="user-addit">Add</span>
</div>
</div>
</div>
</div>
</div>
)
}
ReactDOM.render(<Favourites/>,document.getElementById('root') );
使用此方法,在包括react-slick插件https://github.com/akiran/react-slick之前,一切正常 CDN链接:https://cdnjs.com/libraries/react-slick
但是当我尝试使用它时会出现错误:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `Favourites`.
我不知道我在做什么错。请帮助