点击按钮时Vue.js刷新页面

时间:2021-03-26 04:38:01

标签: html vue.js button onclick page-refresh

我想在点击按钮时刷新页面 这是按钮在 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')

1 个答案:

答案 0 :(得分:0)

 methods: {
    getUser() {
        window.location.reload()
    }
  }
相关问题