【发布时间】:2021-03-26 04:38:01
【问题描述】:
我想在点击按钮时刷新页面
这是按钮在 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')
【问题讨论】:
-
你想在哪里刷新你的页面?
-
async getUser() { $forceUpdate(); } -
为什么要刷新页面?我问了这个问题,也许您正在寻找其他东西。
-
我点击按钮,然后转到
getUser() {} -
好吧,我明白了。但是为什么要刷新页面而不重新加载?
标签: html vue.js button onclick page-refresh