Question 31
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
index.html:
<div id = "app"> <input v-model = "name" @input = "do_something"> <p> {{age}} </p></div><script scr = "app.js"></script>app.js:
new Vue({ el : "#app", data : { name : "#app", age : 0, },
mounted () { try { this.name = localStorage.getItem("name").split(" ")[0]; this.age = localStorage.getItem("name").split(" ")[1]; localStorage.setItem("name", localStorage.getItem("name").split(" ")[0] + " " + this.name); } catch { this.name = "Default"; this.age = "Default"; }
},
methods : { do_something() { localStorage.setItem("name", this.name); localStorage.setItem("age", this.age); } }})Suppose you open “index.html” file in a browser, and type the text “IIT Madras” in the text box shown (after removing the previous text, if any), and hard refresh the page twice, without clicking anywhere. What will be the value shown in the text box, and the “age” placeholder, respectively?
The app will show an error in the console
Default, Default
IIT, Madras
IIT, IIT
Madras, IIT
None of these