VUE2.6.10——入口文件

  • /src/platforms/web/entry-runtime-with-compiler.js
  • /src/platforms/web/runtime/index.js

entry-runtime-with-compiler.js

entry-runtime-with-compiler.js 入口文件爲Vue重寫了$mount方法,並添加了compile方法。vue

$mount

$mount 方法支持傳入 2 個參數。web

  • 第一個是 el,它表示掛載的元素,能夠是字符串,也能夠是 DOM 對象。第二個參數是和服務端渲染相關,在瀏覽器環境下不須要傳第二個參數。
  • 若是Vue實例option中沒有render函數,會把option.template中的內容經過編輯器compileToFunctions編譯成render函數,而後再調用Vue的$mount方法。

compile

--暫時沒看明白,回頭再看api

/src/platforms/web/runtime/index.js

  • 添加平臺特有的函數、變量、指令、組件
  • 定義$mount方法,調用mountComponent掛載組件

參考資料

相關文章
相關標籤/搜索