Question 15
Consider the below application with markup “index.html” and javascript file “app.js”.
index.html:
<body> <div id="app"></div> <scriptsrc="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> <scriptsrc="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script> <script src="app.js" type="module"></script> </body>app.js:
const overs = { 1: [2, 3, 4, 6, 2], 2: [3, 2, 5, 3, 1],}
const NotFound = { template: `<div> Over Not Found</div>` }const MatchNotStarted = { template: `<div>Match has not yet started.</div>` }
const currentOver = { template: `<div style='display: flex'><div v-for='run in over' style='padding: 10px'>{{run}}</div></div>`, data() { return { over: overs[this.$route.params.overNo] ? overs[this.$route.params.overNo] : overs[2], } },}
const liveScore = { template: `<div>Total Score:{{totalScore}} <router-view /></div>`, data() { return { totalScore: 100, } },}
const router = new VueRouter({ routes: [ { path: '/live-score', component: liveScore, children: [ { path: '', component: MatchNotStarted }, { path: 'over/:overNo', component: currentOver }, ], }, ],})
new Vue({ el: '#app', template: `<div><router-view /></div>`, router,})Suppose the application is running on “http://127.0.0.1:8080”. What will be rendered in the “router-view” component of the “live-score” component for URL “http://localhost:8080/#/live-score/over/2”?
Total Score:100
Match has not yet started.
2 3 4 6 2
3 2 5 3 1