Rowan Liu's Tech
Home
Blog
CSS
JS
lib
Read
About
GitHub
Home
Blog
CSS
JS
lib
Read
About
GitHub
  • 框架
  • Vue ClI 源码探索
  • vue 源码解读

    • Vue.js技术揭秘
    • Flow
    • Vue.js源码目录设计
    • Vue.js源码构建
    • 从入口开始
    • 数据驱动
    • new Vue发生了什么
    • Vue实例挂载的实现
    • render
    • Virtual DOM
    • createElement
    • update
    • 组件化
  • threejs journey

    • three.js
    • 第一章我们做了什么
    • 基本组件
    • 光源
    • 材质
    • 学习使用几何体
    • 高级几何体和二元操作
    • 粒子和粒子系统
    • 创建、加载高级网格和几何体
    • /lib/threejs/webgl/
  • react journey

    • React
    • Ant Design
  • vuepress

    • 评论
  • egg

    • egg init
  • jQuery系列

    • jQuery一个在JavaScript基础之上封装的函数库。
  • nestjs

    • OAuth 2.0
    • [译]Passport 文档(一)入门
    • [译]Passport 文档(二)提供者
    • [译]Passport 文档(三)基本 & 摘要
    • [译]Passport 文档(四)操作

Vue.js源码构建

Vue.js源码是通过Rollup构建的,配置在build目录下。

Runtime only VS Runtime + Compiler

使用Runtime only时,需要借助如webpack的vue-loader工具把.vue文件编译成JavaScript,因为这是在编译阶段做的,所以Runtime only只包含运行时的Vue.js代码,因此代码体积也更轻量。

Runtime+Compiler的使用 如果我们没有对代码做预编译,但又使用了Vue的template属性并传入了一个字符串,则需要在客户端编译模板。

// 需要编译器的版本
new Vue({
  template: '<div>{{ hi }}</div>'
})

// 不需要编译的版本
new Vue({
  render(h){
    return h('div', this.hi)
  }
})

总结

通过这节,我们了解了Vue.js的构建过程。也知道了Vue.js的Runtime Only和Runtime Compiler的区别。

Edit this page
Last Updated: 2026/1/12 10:15
Contributors: Rowan Liu
Prev
Vue.js源码目录设计
Next
从入口开始