我正在尝试按照react-phone-number-input
以下方式集成一个名为我的多步反应表单的库:
import React, {useState} from 'react'
import Helmet from 'react-helmet'
import './reg-style/Credentail.css'
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
export default function Credential (){
continue = e => {
e.preventDefault();
this.props.nextStep();
};
back = e => {
e.preventDefault();
this.props.prevStep();
};
const [ values, handleChange ] = this.props;
const [value, setValue] = useState()
return (
<div>
<Helmet>
<body className="form-bg-col"></body>
</Helmet>
<div className="login">
<div className="reg-container">
<button onClick={this.back} className="col-form-prev"><i class="fa fa-chevron-left"></i></button>
<div className="user-detail email">
Email:
<input onChange={handleChange('Email')} defaultValue={values.Email} type="email" placeholder="Enter your Email"/>
</div>
<div className="user-detail"
onChange={handleChange('Phone')} defaultValue={values.Phone}
>
Phone:
<PhoneInput
displayInitialValueAsLocalNumber
placeholder="Enter phone number"
defaultCountry="IN"
value={value}
onChange={setValue}
/>
</div>
<div className="user-detail username">
Username:
<input onChange={handleChange('Username')} defaultValue={values.Username} type="text" placeholder="Select your unique Username" />
</div>
<div className="user-detail password">
Password:
<input onChange={handleChange('Password')} defaultValue={values.Password} type="password" placeholder="Choose your Password" />
</div>
<button onClick={this.continue} className="col-form-next"><i class="fa fa-chevron-right"></i></button>
</div>
</div>
</div>
)
}
在运行它时,我收到一个错误:
`./src/form/register/Credential.js
Line 9:14: Parsing error: Unexpected token
7 |
8 | export default function Credential (){
> 9 | continue = e => {
| ^
10 | e.preventDefault();
11 | this.props.nextStep();
12 | };`
我应该怎么做才能摆脱这个错误,你的帮助对我来说非常有价值