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"> <h3>Vue Js Decode JSON Object</h3> <p>JSON string: {{ jsonString }}</p> <button @click="decodeJson">Decode</button> <p v-if="person">Name: {{ person.name }}, Age: {{ person.age }}</p> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { jsonString: '{"name": "John", "age": 30}', person: null }; }, methods: { decodeJson() { this.person = JSON.parse(this.jsonString); } } }); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; padding: 20px; background-color: #f9f9f9; } h3 { font-size: 24px; margin-bottom: 20px; } button { padding: 10px 20px; background-color: #008CBA; color: #fff; border: none; border-radius: 4px; font-size: 18px; cursor: pointer; margin-bottom: 20px; } button:hover { background-color: #005b81; } p { font-size: 18px; margin-bottom: 0; } </style> </body> </html>