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 Encode Json Object</h3> <button @click="encodeObject">Encode Object</button> <p>Encoded JSON: {{ encodedJson }}</p> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { myObject: { name: "John", age: 30, city: "New York" }, encodedJson: "" }; }, methods: { encodeObject() { this.encodedJson = JSON.stringify(this.myObject); } } }); </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>