Created
April 18, 2020 00:17
-
-
Save lmiller1990/f6b9f6c5fa28e4e6cb4089b5765cb4c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue/dist/vue.esm.js' | |
import VueRouter from 'vue-router' | |
import BS from 'bootstrap-vue' | |
Vue.config.productionTip = false | |
Vue.use(BS) | |
Vue.use(VueRouter) | |
const Home = { template: '<div>This is Home</div>' } | |
const Foo = { template: '<div>This is Foo</div>' } | |
const Bar = { template: '<div>This is Bar {{ $route.params.id }}</div>' } | |
const router = new VueRouter({ | |
mode: 'history', | |
base: __dirname, | |
routes: [ | |
{ path: '/', name: 'home', component: Home }, | |
{ path: '/foo', name: 'foo', component: Foo }, | |
{ path: '/bar/:id', name: 'bar', component: Bar } | |
] | |
}) | |
new Vue({ | |
router, | |
template: ` | |
<div id="app"> | |
<h1>Named Routes</h1> | |
<p>Current route name: {{ $route.name }}</p> | |
<ul> | |
<b-nav-item :to="{ name: 'Home' }">Home</b-nav-item> | |
<li><router-link :to="{ name: 'home' }">home</router-link></li> | |
<li><router-link :to="{ name: 'foo' }">foo</router-link></li> | |
<li><router-link :to="{ name: 'bar', params: { id: 123 }}">bar</router-link></li> | |
</ul> | |
<router-view class="view"></router-view> | |
</div> | |
` | |
}).$mount('#app') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment