[Vue] Get up and running with vue-router
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Vue] Get up and running with vue-router相关的知识,希望对你有一定的参考价值。
How do we set up a simple app with its own routes with their own components in Vue?
Install:
npm i --save vue-router
Define routers:
import Vue from ‘vue‘ import Router from ‘vue-router‘ Vue.use(Router) import Armenian from ‘../components/Armenian.vue‘ import Chinese from ‘../components/Chinese.vue‘ import Greek from ‘../components/Greek.vue‘ export default new Router({ mode: ‘history‘, routes: [{ path: ‘/armenian‘, component: Armenian }, { path: ‘/chinese‘, component: Chinese }, { path: ‘/greek‘, component: Greek }] })
Navgiation:
<template> <div id="app"> <header> <router-link to="/" exact>Lorem Ipsum in different languages</router-link> </header> <nav> <ul> <li> <router-link to="/armenian">Armenian</router-link> </li> <li> <router-link to="/chinese">Chinese</router-link> </li> <li> <router-link to="/greek">Greek</router-link> </li> </ul> </nav> <router-view></router-view> </div> </template> <script> export default { name: ‘App‘ } </script> <style> .router-link-active { color: turquoise } </style>
以上是关于[Vue] Get up and running with vue-router的主要内容,如果未能解决你的问题,请参考以下文章
Setting up Storm and Running Your First Topology
[DevOps] Set up and run a PostgreSQL instance locally with Docker Compose
vue cli 使用npm run dev 报错Cannot GET /