我正在尝试从另一个组件调用一个组件以显示一些 html,如果我单独调用该组件,它可以工作,但是如果我在同一个返回函数中添加更多标记,则会引发以下错误:
Adjacent JSX elements must be wrapped in an enclosing tag (9:12) while parsing file
产品.jsx
var React = require('react');
var Product = React.createClass({
render: function() {
return (<p>Product</p>);
}
});
module.exports = Product;
ProductSlider.jsx(作品)
var React = require('react');
var Product = require('./Product.jsx');
var ProductSlider = React.createClass({
render: function() {
return (
<div><Product /></div>
);
}
});
module.exports = ProductSlider;
ProductSlider.jsx(不起作用)
var React = require('react');
var Product = require('./Product.jsx');
var ProductSlider = React.createClass({
render: function() {
return (
<div><Product /></div>
<div><p>Something else</p></div>
);
}
});
module.exports = ProductSlider;
有人知道这段代码有什么问题吗?