screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h1>Vue Js reload/refresh image with same URL onClick</h1> <img :src="imageUrl" @click="reloadImage"> <small>Url: {{imageUrl}}</small> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { imageUrl: "https://www.sarkarinaukriexams.com/images/post/1684080560tree-g37135fa70_640.jpg", }; }, methods: { reloadImage() { const timestamp = new Date().getTime(); this.imageUrl = `https://www.sarkarinaukriexams.com/images/post/1684080560tree-g37135fa70_640.jpg?${timestamp}`; } } }) </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; font-family: Arial, sans-serif; padding: 20px; } h1 { margin-top: 0; } img { max-width: 100%; height: auto; cursor: pointer; margin-bottom: 10px; } small { font-size: 14px; } </style> </body> </html>