我在 Laravel 应用程序中使用 ElementUI,我面临的问题是 v-model 指令不起作用。我也尝试过输入正常输入,但 v-model 指令仍然不起作用。
export default {
props: ['cardHeading'],
data() {
return {
formData: {
name: 'asdf',
password: ''
},
csrfToken: window.Laravel.csrfToken
}
},
methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!');
} else {
console.log('error submit!!');
return false;
}
});
}
},
mounted() {
console.log(this.formData);
}
}
<el-form ref="form" label-position="right" :model="formData" label-width="100px">
<h1>{{cardHeading}}</h1>
<input type="hidden" name="_token" :value="csrfToken">
<el-form-item label="Email: ">
<el-input type="email" v-model="formData.name"></el-input>
</el-form-item>
<el-form-item label="Password: ">
<el-input type="password" suffix-icon="fa-icon-view" v-model="formData.password"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" round>Create<i class="el-icon-d-arrow-right"></i></el-button>
</el-form-item>
</el-form>