vue index .html渲染原理


index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>hsd</title>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

 

main.js

// 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 App from './App'//導入組件
import router from './router'
Vue.config.productionTip = false
new Vue({//新建vue對象
  el: '#app',//vue實例掛載作用域
  router,
  components: { App },//注冊組件
  template: '<App/>'//模板,使用<App></App>代表掛載元素的內容即index.html中的<div id="app"></div>中的內容
})

App.vue

<template>
  <div id="app">
      <router-view/>
  </div>
</template>
<script>
export default {
  name: 'App'
}
</script>

用模板<App></App>代表掛載元素的內容后,app.vue組件以及其自組件中的內容就渲染在了index.html中

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM