[英]React component import not recognized
我正在尝试使用这个宝石:
http://kyleamathews.github.io/react-component-gallery/
所以我使用npm
安装了它
npm install react-component-gallery
我创建了一个这样的 React 组件:
var Gallery = React.createClass({
render: function() {
return (
<ComponentGallery
className="example"
margin=10
noMarginBottomOnLastRow=true
widthHeightRatio=3/5
targetWidth=250>
<img src="https://example.com/pic1.jpg" />
<img src="https://example.com/pic2.jpg" />
<img src="https://example.com/pic3.jpg" />
<img src="https://example.com/pic4.jpg" />
<img src="https://example.com/pic5.jpg" />
<img src="https://example.com/pic6.jpg" />
<img src="https://storage.googleapis.com/relaterocket-logos/nike.com-black@2x.png" />
<img src="https://storage.googleapis.com/relaterocket-logos/gopro.com-black@2x.png" />
</ComponentGallery>
);
}
});
但是我收到此错误:
JSX value should be either an expression or a quoted JSX t
ext (10:11)
第 10 行是这样的:
margin=10
为什么会出现这种情况?
JSX 类似于 XML。 您的属性值需要是带引号的字符串、表达式或其他 JSX 元素。 在你的情况下,例如
margin="10"
noMarginBottomOnLastRow={true}
(第二个可能是"true"
,只是给出一个表达式的例子。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.