Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
  <header>
    <nav>
      <a v-link="{ path: '/about' }">About</a>
      <a v-link="{ path: '/work' }">Work</a>
      <a v-link="{ path: '/contact' }">Contact</a>
    </nav>
  </header>

  <div class="container">
    <router-view transition transition-mode="out-in"></router-view>
  </div>

  <template id="about-component-template">
    <div>
      <h1>This is the About Section!</h1>
    </div>
  </template>

  <template id="work-component-template">
    <div class="work">
      <h1>This is the Work Section!</h1>
      <a v-link="{ path: '/work/subroute1' }">View SubRoute 1</a>
      <a v-link="{ path: '/work/subroute2' }">View SubRoute 2</a>
      <!-- Read about "transition mode" here: https://vuejs.org/guide/components.html#transition-mode -->
      <router-view transition transition-mode="out-in"></router-view>
    </div>
  </template>
  
  <template id="subroute-component-template">
    <div class="subroute" :style="{ background: color }">
      <p>Hey there. You've reached Work subRoute {{ number }}</p>
    </div>
  </template>

  <template id="contact-component-template">
    <div>
      <h1>This is the Contact Section!</h1>
    </div>
  </template>

</div>
              
            
!

CSS

              
                body {
  font-family: "Trebuchet MS", Helvetica, sans-serif;
}

header {
  height: 80px;
  nav {
    float: right;
    margin-top: 30px;
  }
}

a {
  margin-right: 30px;
}

.container {
  margin: 50px 0 0 30px;
}

.subroute {
  margin: 30px 50px 0 0;
  padding: 20px;
}

// Note: When no transition class name is provided, these are the default transition classes 
// that will control the transition in the<router-view transition></router-view> tags.

.v-transition {
  transition: opacity .1s ease-out;
}
  
.v-enter, .v-leave {
  opacity: 0;
}

// However, they can be named, i.e. <view-router transition="fade"></view-router>
// would be controlled by .fade-transition, .fade-enter, and .fade-leave
// https://vuejs.org/guide/transitions.html
              
            
!

JS

              
                Vue.use(VueRouter);

var AboutComponent = Vue.extend({
  template: "#about-component-template"
});

var WorkComponent = Vue.extend({
  template: "#work-component-template"
});

var SubRoute1Component = Vue.extend({
  template: '#subroute-component-template',
  data() {
    return {
      number: 1,
      color: "#EAFFD0"
    }
  }
});

var SubRoute2Component = Vue.extend({
  template: '#subroute-component-template',
  data() {
    return {
      number: 2,
      color: "#95E1D3"
    }
  }
});

var ContactComponent = Vue.extend({
  template: "#contact-component-template"
});

var router = new VueRouter();

router.map({
  '/about': {
    component: AboutComponent
  },
  '/work': {
    component: WorkComponent,
    subRoutes: {
      '/subroute1': {
        component: SubRoute1Component
      },
      'subroute2': {
        component: SubRoute2Component
      }
    }
  },
  '/contact': {
    component: ContactComponent
  }
});

var App = Vue.extend({});
router.start(App, "#app");
              
            
!
999px

Console