在注册模块中,async registerHandler()这个promise方法看不太懂,不是很明白,请大佬指点
还有就是一般我们vue的data()中直接return:名字:‘ ’。这个是什么意思
[JavaScript] 纯文本查看 复制代码 Vue.http.options.root = '${pageContext.request.contextPath}'; Vue.http.options.emulateJSON = true;
Vue.http.options.xhr = {withCredentials: true};
Vue.use(window.VueQuillEditor);
let vm = new Vue({
el: "#app",
data() {
return {
actiontype: 'save',
errors: {},
hostHead: '${pageContext.request.contextPath}',
"huiyuan": {
"accountname": "",
"password": "",
"email": "",
"idcardno": "",
"nickname": "",
"name": "",
"sex": "",
"touxiang": "/upload/nopic.jpg",
"des": ""
},
}
},
methods: {
async registerHandler() {
let defaultOptions = {
url: "admin/huiyuan/save",
actionTip: "注册成功"
};
const validRes=this.myValidator.valid(this,{isShowErrors:true});
console.log("valRes",validRes);
if (!validRes)
return ;
let util = new VueUtil(this);
let params = {...this.huiyuan};
let {data: res} = await util.http.post(defaultOptions.url, params);
if (res.stateCode <= 0) {
util.alert(res.des, '系统提示', {
confirmButtonText: '确定'
});
return;
}
util.message({
message: defaultOptions.actionTip,
type: 'success',
duration: 2000
});
window.location.href = this.hostHead + "/e/regresult.jsp";
}
},
created() {
console.log("注册创建");
}
});
|