screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> </head> <body> <div id="app"> <h3>Vue 3 Get Client IP Address</h3> <p>Your IP address is: {{ ipAddress }}</p> </div> <script type="module"> const { createApp, ref, onMounted } = Vue; createApp({ setup() { const ipAddress = ref(null); onMounted(() => { axios .get('https://api.ipify.org?format=json') .then(response => { ipAddress.value = response.data.ip; }) .catch(error => { console.error(error); }); }); return { ipAddress }; } }).mount("#app"); </script> <style scoped></style> </body> </html>