Reactjs 您可能需要适当的加载程序来处理此文件类型。
我刚刚制作了一个带有npm的包,发布并安装回fresh project,但它给出了上述错误Reactjs 您可能需要适当的加载程序来处理此文件类型。,reactjs,npm,babeljs,Reactjs,Npm,Babeljs,我刚刚制作了一个带有npm的包,发布并安装回fresh project,但它给出了上述错误 > ./node_modules/react-js-validator/src/inputs/EmailInput.js Module parse failed: Unexpected token (38:12) You may need an appropriate loader to handle this file type. | render() { | return
> ./node_modules/react-js-validator/src/inputs/EmailInput.js
Module parse failed: Unexpected token (38:12)
You may need an appropriate loader to handle this file type.
| render() {
| return (
| <div >
| <span className="error-span" style={this.props.styleError} >
| {this.state.errorStatus ? this.state.errorMsg : null}
我刚刚得到的答案是,我们不能在npm包中使用纯html代码进行react。使用这样的代码
render() {
let collection = React.createElement("div", {},
React.createElement("span", { className: 'error-span' }, this.state.errorMsg),
React.createElement("input", {
type: "text",
onChange: (e) => this.Valid(e.target.value),
onClick: (e) => this.props.return(this.state.errorStatus)
}
)
)
return (collection)
}
render() {
let collection = React.createElement("div", {},
React.createElement("span", { className: 'error-span' }, this.state.errorMsg),
React.createElement("input", {
type: "text",
onChange: (e) => this.Valid(e.target.value),
onClick: (e) => this.props.return(this.state.errorStatus)
}
)
)
return (collection)
}