File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
src/components/Msg/MsgForm Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ export default class MsgForm extends Component {
79
79
}
80
80
81
81
/* 同样地,提交表单前需要根据当前 mode 进行对应的操作 */
82
- handleSubmit ( ) {
82
+ handleSubmit ( evt ) {
83
+ evt . preventDefault ( )
83
84
let { pathname } = this . props . location
84
85
let opt = isAddMode ( pathname ) ? 'addMsg' : 'modMsg'
85
86
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import React from 'react'
9
9
// (因为箭头函数没有自己的 this!无法通过 call/apply 改变)
10
10
export default function ( ) {
11
11
return (
12
- < form >
12
+ < form onSubmit = { ( e ) => this . handleSubmit ( e ) } >
13
13
< div className = "form-group" >
14
14
< label htmlFor = "title" > 标题</ label >
15
15
< input
@@ -45,9 +45,8 @@ export default function () {
45
45
</ div >
46
46
< div className = "btn-group" role = "group" >
47
47
< button
48
- type = "button"
49
- className = "btn btn-success"
50
- onClick = { ( ) => this . handleSubmit ( ) } >
48
+ type = "submit"
49
+ className = "btn btn-success" >
51
50
提交
52
51
< span className = "glyphicon glyphicon-ok" > </ span >
53
52
</ button >
You can’t perform that action at this time.
0 commit comments