Question 11
Consider the below application with markup “index.html” and javascript file “app.js”.
index.html:
<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>app.js:
const data = { 1: { totalRun: 1000, totalMatches: 20 }, 2: { totalRun: 7000, totalMatches: 100 },}const NotFound = { template: `<div> Player Not Found</div>` }const Profile = { template: `<div>Run: {{stat.totalRun}}, Matches:{{stat.totalMatches}}, Average: {{average}}</div>`, data() { return { stat: data[this.$route.params.id], } }, computed: { average() { return this.stat.totalRun / this.stat.totalMatches }, },}const router = new VueRouter({ routes: [ { path: '/profile/:id', component: Profile }, { path: '*', component: NotFound }, ],})
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 inside the “router-view” component for the URL “http://127.0.0.1:8080/#/”?