Question 15
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
index.html:
<body> <div id="app"> <h4 id="total">Total Run: {{total}}</h4> <h4 id="player">{{Player.name}}: {{Player.run}}</h4> <button @click="extra=true">Extra</button> <button @click="addRuns(4)">Run</button> </div> <scriptsrc="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script> <script src="app.js"></script> </body>app.js:
new Vue({ el: '#app', data: { extra: false, total: 20, Player: { name: 'M.S. Dhoni', run: 10 } },
methods: { addRuns(run) { if (this.extra === true) { this.Player.run += run } this.total += run this.extra = false }, },})Suppose the application is running on ‘http://localhost:8080’. If the user clicks on the button with the text “Extra”, and then clicks on the button with the text “Run” twice. What will be rendered inside the element with ID “total” and “player”, respectively?
Total Run: 24, M.S. Dhoni: 14
Total Run: 28, M.S. Dhoni: 14
Total Run: 24, M.S. Dhoni: 18
Total Run: 28, M.S. Dhoni: 18