我想在点击按钮时刷新页面
这是按钮在 html <button v-on:click="getUser()" :class='gender'>Get Random User</button>
下的js代码
const app = Vue.createApp({
data() {
return {
firstName: 'John',
lastName: 'Doe',
email: 'John@Doe.com',
gender: 'male',
picture: 'https://picsum.photos/200',
profile: 'Profile',
}
},
methods: {
async getUser() {
$forceUpdate();
}
}
})
app.mount('#app')
答案 0 :(得分:0)
methods: {
getUser() {
window.location.reload()
}
}