码迷,mamicode.com
首页 > 其他好文 > 详细

一个简单的完整的示范

时间:2018-06-10 15:14:07      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:import   work   initial   sans   highlight   rom   charset   view   exp   

D:\workspace\xxx\index.html   没动过

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>xxx</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

  

D:\workspace\xxx\src\main.js

import Vue from ‘vue‘
import App from ‘./App‘
import VueRouter from ‘vue-router‘
import Apple from ‘@/components/Apple‘
import Banana from ‘@/components/Banana‘

Vue.use(VueRouter)

let router = new VueRouter({
  routes: [
    {
      path: ‘/apple‘,
      component: Apple
    },
    {
      path: ‘/banana‘,
      component: Banana
    }
  ]
})
/* eslint-disable no-new */
new Vue({
  el: ‘#app‘,
  router,
  template: ‘<App/>‘,
  components: { App }
})

  

D:\workspace\xxx\src\App.vue

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <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>

  

D:\workspace\xxx\src\components\Apple.vue

<template>
    <a >{{ msg }}</a>
</template>

<script>
export default {
  name: ‘Apple‘,
  data () {
    return {
      msg: ‘I am an apple‘
    }
  }
}
</script>

  

 D:\workspace\xxx\src\components\Banana.vue

<template>
    <a >{{ msg }}</a>
</template>

<script>
export default {
  name: ‘Banana‘,
  data () {
    return {
      msg: ‘I am a banana‘
    }
  }
}
</script>

  

效果

技术分享图片

技术分享图片

 

技术分享图片

 

一个简单的完整的示范

标签:import   work   initial   sans   highlight   rom   charset   view   exp   

原文地址:https://www.cnblogs.com/tabCtrlShift/p/9162612.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!