第一次在项目里用vuejs 提交表单时候遇到问题,代码如下
html:
<div id="pMsg">
<form @submit.prevent="submit">
<div style="margin-top:30px;" class="ui-form-item"> <label class="ui-label mt10"><span class="ui-form-required">* </span>派出所名称: </label>
<input class="ui-input" type="text" name="polStsName_s" id="polStsName_s" v-model="policeSMsg.polStsName_s" data-is="isAmount isEnough" autocomplete="on" disableautocomplete="">
</div>
<div class="ui-form-item"> <label class="ui-label mt10">备注: </label>
<textarea rows="4" cols="20" data-is="isAmount isEnough" style="resize: none;" v-model="policeSMsg.polStsName_s" name="remark_s"></textarea>
</div>
<div class="widthdrawBtBox">
<input type="submit" id="subutton" class="block-btn" value="确认提交">
</div>
<input type="hidden" v-model="policeSMsg.ID_INCREMENT" name="ID_INCREMENT" value="Y">
</form>
</div>
js:
var policeSMsg = new Vue({
el : '#pMsg',
data :{
policeSMsg:{}
},
method: {
submit:function(){
console.log('进入程序');
var formData = JSON.stringify(this.policeSMsg);
var url= 'http://' + changeAddr() + '/common/saveModel?className=region&checkUniq=N';
console.log(formData+'--------------'+url);
return;
this.$http.post(url, formData).then(function(response) {
// success callback
},function(err) {
// err callback
});
}
}
})
现在的效果就是我点提交按钮后页面直接刷新,并没有进入到submit中...
@submit.prevent="submit"
放到提交按钮上