Question 8
Consider the following Vue application with markup “index.html” and JavaScript file “app.js”.
index.html:
<div id = "app"> <input v-model = "course" @input = "do_something"> <p> {{role}} </p></div>app.js:
new Vue({ el : "#app", data : { course : "#app", role : "user", },
mounted () { try { this.course = localStorage.getItem("course").split(" ")[0]; this.role = localStorage.getItem("course").split(" ")[1]; localStorage.setItem("course", localStorage.getItem("course").split(" ")[0] + " " +this.course); } catch { this.course = "MAD_II"; this.role = "admin"; } },
methods : { do_something() { localStorage.setItem("course", this.course); localStorage.setItem("role", this.role); } }})Suppose you open “index.html” file in a browser, and type the text “App Dev” 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?
MAD_II, admin
App, Dev
App, App
Dev, App