Forráskód Böngészése

Add vue-router and basic scaffolding

sbkwgh 8 éve
szülő
commit
194218de6e
5 módosított fájl, 41 hozzáadás és 78 törlés
  1. 2 1
      package.json
  2. 7 17
      src/App.vue
  3. 0 53
      src/components/Hello.vue
  4. 15 0
      src/components/routes/Index.vue
  5. 17 7
      src/main.js

+ 2 - 1
package.json

@@ -9,7 +9,8 @@
     "build": "node build/build.js"
   },
   "dependencies": {
-    "vue": "^2.1.0"
+    "vue": "^2.1.0",
+    "vue-router": "^2.1.1"
   },
   "devDependencies": {
     "autoprefixer": "^6.4.0",

+ 7 - 17
src/App.vue

@@ -1,28 +1,18 @@
 <template>
-  <div id="app">
-    <img src="./assets/logo.png">
-    <hello></hello>
-  </div>
+	<div id="app">
+		<router-view></router-view>
+	</div>
 </template>
 
 <script>
-import Hello from './components/Hello'
 
 export default {
-  name: 'app',
-  components: {
-    Hello
-  }
+	name: 'app',
+	components: {
+	}
 }
 </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>

+ 0 - 53
src/components/Hello.vue

@@ -1,53 +0,0 @@
-<template>
-  <div class="hello">
-    <h1>{{ msg }}</h1>
-    <h2>Essential Links</h2>
-    <ul>
-      <li><a href="https://vuejs.org" target="_blank">Core Docs</a></li>
-      <li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li>
-      <li><a href="https://gitter.im/vuejs/vue" target="_blank">Gitter Chat</a></li>
-      <li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li>
-      <br>
-      <li><a href="http://vuejs-templates.github.io/webpack/" target="_blank">Docs for This Template</a></li>
-    </ul>
-    <h2>Ecosystem</h2>
-    <ul>
-      <li><a href="http://router.vuejs.org/" target="_blank">vue-router</a></li>
-      <li><a href="http://vuex.vuejs.org/" target="_blank">vuex</a></li>
-      <li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li>
-      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li>
-    </ul>
-  </div>
-</template>
-
-<script>
-export default {
-  name: 'hello',
-  data () {
-    return {
-      msg: 'Welcome to Your Vue.js App'
-    }
-  }
-}
-</script>
-
-<!-- Add "scoped" attribute to limit CSS to this component only -->
-<style scoped>
-h1, h2 {
-  font-weight: normal;
-}
-
-ul {
-  list-style-type: none;
-  padding: 0;
-}
-
-li {
-  display: inline-block;
-  margin: 0 10px;
-}
-
-a {
-  color: #42b983;
-}
-</style>

+ 15 - 0
src/components/routes/Index.vue

@@ -0,0 +1,15 @@
+<template>
+	<div>
+		Index
+	</div>
+</template>
+
+<script>
+	export default {
+		name: 'index'
+	}
+</script>
+
+<style lang='scss' scoped>
+	
+</style>

+ 17 - 7
src/main.js

@@ -1,11 +1,21 @@
-// The Vue build version to load with the `import` command
-// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
 import Vue from 'vue'
+import VueRouter from 'vue-router'
+
 import App from './App'
+import Index from './components/routes/Index'
 
-/* eslint-disable no-new */
-new Vue({
-  el: '#app',
-  template: '<App/>',
-  components: { App }
+Vue.use(VueRouter)
+
+const router = new VueRouter({
+	routes: [
+		{ path: '/', component: Index }
+	],
+	mode: 'history'
 })
+
+new Vue({
+	el: '#app',
+	template: '<App/>',
+	components: { App },
+	router
+})