vue項目中app.vue 、main.js和 index.html的關聯

1.main.js是咱們的入口文件,主要做用是初始化vue實例並使用須要的插件。vue

import Vue from 'vue'
import App from './App'

/* eslint-disable no-new */
new Vue({
  el: '#app',
  template: '<App/>',
  components: { App }
})

2.App.vue是咱們的主組件,全部頁面都是在App.vue下進行切換的。其實你也能夠理解爲全部的路由也是App.vue的子組件。因此我將router標示爲App.vue的子組件。web

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <hello></hello>
  </div>
</template>

<script>
import Hello from './components/Hello'

export default {
  name: 'app',
  components: {
    Hello
  }
}
</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>
相關文章
相關標籤/搜索