function login() { return Vue.component('login', function (resolve, reject) { axios.get("/login.html").then(function (response) { resolve({ template: response.data, data() { return { name: 'login' }; }, mounted: function () { console.log('mounted:login'); weui.form.checkIfBlur('#form', this.regexp); }, computed: { regexp: function () { return { regexp: { userName: /^[^\s]+/, password: /^[^\s]+$/ } }; } }, methods: { submit: function () { weui.form.validate('#form', function (error) { console.log(error); if (!error) { var loading = weui.loading('提交中...'); var form = $("#form"); var url = form.attr('action'); $.ajax({ url: url, type: "POST", data: form.serializeJSON(), contentType: "application/json", success: function (response) { loading.hide(); weui.toast(response, 3000); } }); } }, this.regexp); } } }) }); }); }