Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Vue Router function.
Vue
import { [1] } from 'vue-router';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
useRouter which is for accessing the router instance, not creating it.Trying to import a function that doesn't exist like
defineRoute.✗ Incorrect
The createRouter function is used to define routes in Vue Router.
2fill in blank
mediumComplete the code to define a route path for the Home component.
Vue
const routes = [{ path: '/', component: [1] }]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase
home which is not a valid component name.Using unrelated names like
Main.✗ Incorrect
The component name Home matches the imported component for the home page.
3fill in blank
hardFix the error in the router creation by completing the missing property.
Vue
const router = createRouter({ history: createWebHistory(), [1] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
path or component which belong inside route objects, not router config.Omitting the routes property entirely.
✗ Incorrect
The routes property is required to tell the router which routes to use.
4fill in blank
hardFill both blanks to define a route with a name and path.
Vue
const routes = [{ name: '[1]', path: '[2]', component: About }]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the name and path values.
Using
/home or home for the About route.✗ Incorrect
The route name is about and the path is /about for the About page.
5fill in blank
hardFill both blanks to create a router with history and routes.
Vue
const router = createRouter({ history: [1](), [2] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
createWebHashHistory when the question expects createWebHistory.Omitting the
routes property or confusing it with others.✗ Incorrect
The router uses createWebHistory() for history and routes for route list.