【发布时间】:2020-12-13 06:02:04
【问题描述】:
每当我尝试单击该按钮时,它都不会添加任何记录。但是当我输入输入字段@keyup.enter="addusers" 然后当我按下回车键时它正在工作。我希望它与添加按钮一起使用。谁能给我建议。
.row
input(type='text', v-model='newUser')
input(type='text', v-model='newMail')
button.btn.btn-primary(type='button' @onclick="addUsers") Add
.col-lg-12.text-left(v-for="user in users")
p {{ user.name}}- {{user.email}}
addUsers() {
axios.post('https://jsonplaceholder.typicode.com/users', {
name: this.newUser,
email: this.newMail
})
.then(({data}) => {
this.users.push(data);
});
【问题讨论】:
-
错字。 “@click”而不是“@onclick”
标签: vue.js vuejs2 axios vue-component pug