We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
浏览器端,入口文件为:
如果我们结合webpack打包来写项目,是vue-loader帮我们做了单文件解析以及compiler,所以入口文件为entry-runtime.js
entry-runtime.js
如果是单独写,类似:
new Vue({ el: '#app', template: '' })
入口文件就是entry-runtime-with-compiler.js
entry-runtime-with-compiler.js
其本质就类似于我们对函数参数类型或值的hack,Vue的options支持传el,template,render参数,这个文件就是对这些参数的处理hack
el
template
render
将得到的template字符串用compiler/index.js中的方法编译后,得到render/staticRenderFns函数,然后重写options.render/options.staticRenderFns,和Vue.prototype.$mount方法
compiler/index.js
render/staticRenderFns
options.render/options.staticRenderFns
Vue.prototype.$mount
核心是
const { render, staticRenderFns } = compileToFunctions(template, { // 2个方法都是判断浏览器是否encode html属性上的值,因为template支持语法 // 是否decode换行符,ie会encode而其他不会 shouldDecodeNewlines, // 是否decode a[href],chrome会encode shouldDecodeNewlinesForHref, // 解析模版字符串的分隔符,默认是`{{ }}` delimiters: options.delimiters, // 是否保留注释,默认false comments: options.comments }, this) options.render = render options.staticRenderFns = staticRenderFns
另外关于runtime/index.js中 初始化时,用extend 挂载了默认的directives,components,和domDiff__patch__
runtime/index.js
extend
directives
components
__patch__
最后,会将得到的options和el根节点传入core/instance/lifecycle mountComponent方法。
core/instance/lifecycle
接下来,我们看mountComponent方法做了哪些事
mountComponent
The text was updated successfully, but these errors were encountered:
No branches or pull requests
浏览器端,入口文件为:
如果我们结合webpack打包来写项目,是vue-loader帮我们做了单文件解析以及compiler,所以入口文件为
entry-runtime.js
如果是单独写,类似:
入口文件就是
entry-runtime-with-compiler.js
其本质就类似于我们对函数参数类型或值的hack,Vue的options支持传
el
,template
,render
参数,这个文件就是对这些参数的处理hack将得到的template字符串用
compiler/index.js
中的方法编译后,得到render/staticRenderFns
函数,然后重写options.render/options.staticRenderFns
,和Vue.prototype.$mount
方法核心是
另外关于
runtime/index.js
中 初始化时,用extend
挂载了默认的directives
,components
,和domDiff__patch__
最后,会将得到的options和el根节点传入
core/instance/lifecycle
mountComponent方法。接下来,我们看
mountComponent
方法做了哪些事The text was updated successfully, but these errors were encountered: