<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
<div id="app">
<h1>Hello App!</h1>
<p>
<!-- use router-link component for navigation. -->
<!-- specify the link by passing the `to` prop. -->
<!-- `<router-link>` will be rendered as an `<a>` tag by default -->
<router-link to="/">Go to Default</router-link><br>
<router-link to="/foo">Go to Foo</router-link><br>
<router-link to="/bar">Go to Bar</router-link><br>
<router-link to="/user/123">Go to User 123</router-link><br>
<router-link to="/user/456">Go to User 456</router-link><br>
</p>
<!-- route outlet -->
<!-- component matched by the route will render here -->
<router-view></router-view>
</div>
// 0. If using a module system (e.g. via vue-cli), import Vue and VueRouter
// and then call `Vue.use(VueRouter)`.
// 1. Define route components.
// These can be imported from other files
const Default = { template: '<div class="squarebubble topbubble" id="toppy"><div class="hamburger hamburger--arrowturn" id="hammy"> <div class="hamburger-box"> <div class="hamburger-inner"></div> </div> </div> <span id="logo">Chatfer</span></div><div id="main"> <div class="squarebubble mainIn" id="lefty">🍌 Bananas are amazing fruit!</div> <div class="squarebubble mainIn" id="righty">🍒 Cherries taste delicious!</div></div>' };
const Foo = { template: '<div>foo</div>' };
const Bar = { template: '<div>bar</div>' };
const User = { template: '<div>User {{ $route.params.id }}</div>' };
// https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changes
// uses Promise & webpack 2 to async load file when the route is visited
const Foo2 = () => import('./Foo2.vue');
// 2. Define some routes
// Each route should map to a component. The "component" can
// either be an actual component constructor created via
// `Vue.extend()`, or just a component options object.
// We'll talk about nested routes later.
const routes = [
{ path: '/', component: Default, name: 'Hello'},
{ path: '/foo', component: Foo, name: 'Hi Foo' },
{ path: '/bar', component: Bar, name: 'Hi Bar' },
{ path: '/user/:id', component: User, name: 'Hi User' },
{ path: '*', redirect: '/' } // redirect for default or 404
];
// 3. Create the router instance and pass the `routes` option
// You can pass in additional options here, but let's
// keep it simple for now.
const router = new VueRouter({
//mode: 'history',
// use full URLs vs # (html5). Requires server rewrite to index if file doesn't exist (for bookmarks)
// NGINX: location / { try_files $uri $uri/ /index.html; }
routes // short for `routes: routes`
});
/* router.replace({ path: '*', redirect: '/'...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.