Question 32
Consider the following application with markup “index.html” and javascript file “app.js”, and answer the given subquestions.
index.html:
<body> <div id="app"> <router-view /> </div> <script src="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"></script></body>app.js:
const Home = { template: `<div> Welcome Home</div>` }const slotComp = { template: `<div> <ol> <li v-for='slot in availableSlots'> {{slot.description}} </li> </ol> </div>`, data() { return { slots: [ { id: 1, description: 'Slot1', status: 'true' }, { id: 2, description: 'Slot2', status: 'true' }, { id: 3, description: 'Slot3', status: 'false' }, ], } }, computed: { availableSlots() { const slots = this.slots.filter((slot) => { return ( slot.status == this.$route.params.status && slot.id > (this.$route.query.offset ? parseInt(this.$route.query.offset) :0) ) }) return slots }, },}const router = new VueRouter({ routes: [ { path: '/', component: Home }, { path: '/slot/:status', component: slotComp }, ],})
new Vue({ el: '#app', router,})1. Slot1
2. Slot21. Slot2
2. Slot31. Slot1
1. Slot2