这次给大家带来vue1与vue2获取dom元素步骤详解,vue1与vue2获取dom元素的注意事项有哪些,下面就是实战案例,一起来看一下。vue1.*版本中在标签中加上el='dom',然后在代码中this.$els.dom这样...
这次给大家带来vue中.vue文件解析步骤详解,vue中.vue文件解析的注意事项有哪些,下面就是实战案例,一起来看一下。
我们平时写的 .vue 文件称为 SFC(Single File Components),本文介绍将 SFC 解析为 descriptor 这一过程在 vue 中是如何执行的。
vue 提供了一个 compiler.parseComponent(file, [options]) 方法,来将 .vue 文件解析成一个 descriptor:// an object format describing a single-file component.
declare type SFCDescriptor = {
template: ?SFCBlock;
script: ?SFCBlock;
styles: Array;
customBlocks: Array;
};
文件入口
解析 sfc 文件的入口在 src/sfc/parser.js 中,该文件 export 了 parseComponent 方法, parseComponent 方法用来对单文件组件进行编译。
接下来我们看看 parseComponent 方法都做了哪些事情。
parseComponent 方法function start(tag, attrs, unary, start, end,){
}