(
data, //tag标签属性数据
Ctor, //组件构造函数VueComponent
tag //tag标签名称
)
| 3163 | * |
| 3164 | * */ |
| 3165 | function extractPropsFromVNodeData( |
| 3166 | data, //tag标签属性数据 |
| 3167 | Ctor, //组件构造函数VueComponent |
| 3168 | tag //tag标签名称 |
| 3169 | ) { |
| 3170 | // we are only extracting raw values here. |
| 3171 | // validation and default values are handled in the child |
| 3172 | // component itself. |
| 3173 | //我们只是在这里提取原始值。 |
| 3174 | //验证和默认值在孩子中被处理 |
| 3175 | //组件本身。 |
| 3176 | |
| 3177 | //获取Ctor 参数中的 props |
| 3178 | var propOptions = Ctor.options.props; //获取组件的props属性 |
| 3179 | console.log(Ctor.options) |
| 3180 | |
| 3181 | //如果propOptions 属性是空或者不存在 这不执行下面代码 |
| 3182 | if (isUndef(propOptions)) { |
| 3183 | return |
| 3184 | } |
| 3185 | |
| 3186 | |
| 3187 | var res = {}; |
| 3188 | var attrs = data.attrs; |
| 3189 | var props = data.props; |
| 3190 | |
| 3191 | //如果data中的属性attrs或者props 属性 数据存在 |
| 3192 | if (isDef(attrs) || isDef(props)) { |
| 3193 | //遍历propOptions props属性中的值 |
| 3194 | for (var key in propOptions) { |
| 3195 | |
| 3196 | //altKey获取到一个函数,该函数功能是把 abCd 驼峰字母改写成 ab-c 如果是 aB cd 则是 ab cd |
| 3197 | //大写字母,加完减号又转成小写了 比如把驼峰 aBc 变成了 a-bc |
| 3198 | //匹配大写字母并且两面不是空白的 替换成 '-' + '字母' 在全部转换成小写 |
| 3199 | |
| 3200 | var altKey = hyphenate(key); |
| 3201 | |
| 3202 | |
| 3203 | { |
| 3204 | //把key 转换成小写 |
| 3205 | var keyInLowerCase = key.toLowerCase(); |
| 3206 | //如果他们key不相同 并且 属性attrs存在 并且keyInLowerCase 属性存在 attrs对象中 |
| 3207 | if ( |
| 3208 | key !== keyInLowerCase && |
| 3209 | attrs && hasOwn(attrs, keyInLowerCase) |
| 3210 | ) { |
| 3211 | //输出一个警告信息 |
| 3212 | tip( |
| 3213 | "Prop \"" + keyInLowerCase + "\" is passed to component " + |
| 3214 | (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + |
| 3215 | " \"" + key + "\". " + |
| 3216 | "Note that HTML attributes are case-insensitive and camelCased " + |
| 3217 | "props need to use their kebab-case equivalents when using in-DOM " + |
| 3218 | "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." |
| 3219 | ); |
| 3220 | } |
| 3221 | } |
| 3222 | //检查属性 |
no test coverage detected