【发布时间】:2017-07-13 09:30:17
【问题描述】:
我已提出以下申请:https://github.com/pc-magas/reaqct-jcrop
我有以下组件,我想在其中使用 jcrop:
import React, { Component } from 'react';
import $ from './MyJquery.js';
import Jcrop from 'jcrop';
class JCrop extends Component {
constructor(props){
super(props)
this.state={
'imageToCrop':props.imageToCrop,
'imageHtmlElement':null
}
}
comonentDidMount() {
$("#img").Jcrop();
}
render(){
return(
<img id="img" rel={ (rel) => {this.setState({imageHtmlElement:rel})} } src={ this.state.imageToCrop } />
)
}
}
export default JCrop
我还创建了./MyJquery.js,以便将 Jquery 对象应用于窗口:
import $,{jQuery} from 'jquery';
window.jQuery = jQuery;
export default $
但是当我通过 npm run 运行应用程序时,出现以下错误:
类型错误:a 未定义
我该如何解决?
【问题讨论】: