我有兴趣让这个反应js nuke carousel工作。 https://github.com/kenwheeler/nuka-carousel
//的jsfiddle https://jsfiddle.net/7xzd92s5/6/
我是否可以使用cdn加载模块?
var Carousel = require('nuka-carousel');
var CarouselApp = React.createClass({
mixins: [Carousel.ControllerMixin],
render() {
return (
<Carousel>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide1"/>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide2"/>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide3"/>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide4"/>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide5"/>
<img src="http://placehold.it/1000x400/ffffff/c0392b/&text=slide6"/>
</Carousel>
)
}
});
ReactDOM.render(
<CarouselApp name="CarouselApp" />,
document.getElementById('CarouselApp')
);
答案 0 :(得分:0)
你写道:
var Carousel = require('nuka-carousel')
但是在jsfiddle服务器上没有安装'nuka-carousel'库。你需要从外部依赖加载'nuka-carousel'作为像这样的babel:
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
jsfiddle-integration-babel.js中没有定义require
函数