///我也在django中编写我的程序,同时也有混合反应。当我在django中创建表单时,默认情况下,它不会在输入标签中放入结束标签“ />”。所以它会在react console中产生关闭标签错误。如何解决。这是我的代码
//forms.py
class SignUpForm(forms.Form):
phone_email = forms.CharField()
//views.py
def sign_up(request):
form = SignUpForm()
return render(request, 'account/sign_up.html', {"form": form})
//sign_up.html
class Sign_up extends React.Component{
render(){
return(
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
</form>
)
}
}
//error
//syntaxError: embedded: Expected corresponding JSX closing tag for <input> (18:143) 16 | <form method="post" action=""> 17 | <input type="hidden" name="csrfmiddlewaretoken" value="UWBCh291YmYuTNYqk9OKsihm7y1JtrFvgRNNoknJY6Be3fH6ov7uytcgcfPC6Yao"> > 18 | <p><label for="id_phone_email">Phone email:</label> <input type="text" name="phone_email" required id="id_phone_email"></p>