main.js index.html與app.vue三者關系詳解


main.js index.html與app.vue三者關系詳解

main.js與index.html是nodejs的項目啟動的首加載頁面資源與js資源,app.vue則是vue頁面資源的首加載項

首先啟動項目 v8找到index.html與main.js, 執行main.js時遇到

根據import加載app.vue文件(.vue文件可以不是叫app 可以是diyName.vue 但沒必要)

然后new Vue的操作是用vue渲染index.html中的"#app" Dom元素渲染規則是 "template: <App/>"直接將其渲染為上一步components調用的局部組件"App"(這兒就可以改為 components:{diyName}, template:'<diyName></diyName>') ;

一般生產使用都是在main.js的new Vue是加上自定義router

 

vue入口文件main.js

 版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/evendetail/article/details/78623097

入口文件與app.vue 相關聯

import Vue from 'vue' // main.js 為入口文件,並與app.vue組件向關聯使此組件為跟組件 // 是所有的內容都在app.vue 上面呈現。 import App from './App' // 在router里配置路由,將app組件相關聯 import router from './router' Vue.config.productionTip = false /* eslint-disable no-new */ // 生成vue的根實例;創建每個組件都會生成一個vue的實列,並且會用到根實例上面的所有屬性 new Vue({ el: '#app', router, // 聲明模版 template: '<App/>', // 注冊成組件 components: { App } })


免責聲明!

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



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