(Vue)
| 7118 | * 为vue 添加 静态方法component,directive,,filter |
| 7119 | * */ |
| 7120 | function initAssetRegisters(Vue) { |
| 7121 | /** |
| 7122 | * Create asset registration methods. |
| 7123 | * |
| 7124 | * |
| 7125 | * // var ASSET_TYPES = [ |
| 7126 | // 'component', //组建指令 |
| 7127 | // 'directive', //定义指令 指令 |
| 7128 | // 'filter' //过滤器指令 |
| 7129 | // ]; |
| 7130 | *为vue 添加 静态方法component,directive,filter |
| 7131 | * |
| 7132 | */ |
| 7133 | ASSET_TYPES.forEach(function (type) { |
| 7134 | |
| 7135 | Vue[type] = function ( |
| 7136 | id, //id |
| 7137 | definition //new Vue拓展参数对象 |
| 7138 | ) { |
| 7139 | console.log(definition) |
| 7140 | |
| 7141 | |
| 7142 | if (!definition) { //如果definition不存在 |
| 7143 | return this.options[type + 's'][id] //返回 |
| 7144 | } else { |
| 7145 | /* istanbul ignore if */ |
| 7146 | if ("development" !== 'production' && type === 'component') { |
| 7147 | // 验证组件名称 必须是大小写,并且是-横杆 |
| 7148 | validateComponentName(id); |
| 7149 | } |
| 7150 | if (type === 'component' && isPlainObject(definition)) { //如果类型是组件 |
| 7151 | definition.name = definition.name || id; //名称如果有定义就获取 如果没有 就按照id的来 |
| 7152 | |
| 7153 | definition = this.options._base.extend(definition); // Class inheritance 类继承 用于vue多个组件中的合并拓展参数 |
| 7154 | |
| 7155 | } |
| 7156 | if (type === 'directive' && typeof definition === 'function') { //如果类型是指令 |
| 7157 | definition = { bind: definition, update: definition }; |
| 7158 | } |
| 7159 | this.options[type + 's'][id] = definition; //返回集合 |
| 7160 | return definition |
| 7161 | } |
| 7162 | }; |
| 7163 | }); |
| 7164 | } |
| 7165 | |
| 7166 | /* |
| 7167 | * 获取组件的名称 |
no test coverage detected