Skip to content

Instantly share code, notes, and snippets.

@yooouuri
Created February 2, 2018 18:54
Show Gist options
  • Select an option

  • Save yooouuri/07949278d01a55035756eda8200b2614 to your computer and use it in GitHub Desktop.

Select an option

Save yooouuri/07949278d01a55035756eda8200b2614 to your computer and use it in GitHub Desktop.
// router.js
import VueRouter from 'vue-router'
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
export default new VueRouter({
routes
})
// main.js
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import router from './router'
Vue.config.productionTip = false
Vue.use(VueRouter)
new Vue({
router,
render: h => h(App)
}).$mount('#app')
// App.vue
<template>
<div id="app">
<router-link to="/foo">Go to Foo</router-link>
<router-link to="/bar">Go to Bar</router-link>
<router-view/>
</div>
</template>
<script>
export default {
name: 'app',
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
// vue.config.js
module.exports = {
lintOnSave: true
}
// package.json
{
"name": "photos",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "^2.5.13",
"vue-router": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0-alpha.6",
"@vue/cli-plugin-eslint": "^3.0.0-alpha.6",
"@vue/cli-service": "^3.0.0-alpha.6",
"vue-template-compiler": "^2.5.13"
},
"babel": {
"presets": [
"@vue/app"
]
},
"eslintConfig": {
"extends": [
"plugin:vue/essential",
"eslint:recommended"
]
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment