MCPcopy Create free account
hub / github.com/ygs-code/vue / parsePath

Function parsePath

vue.js:660–681  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

658 var bailRE = /[^\w.$]/; //匹配不是 数字字母下划线 $符号 开头的为true
659
660 function parsePath(path) {
661 console.log(path)
662
663 if (bailRE.test(path)) { //匹配上 返回 true
664 return
665 }
666 //匹配不上 path在已点分割
667 var segments = path.split('.');
668 return function (obj) {
669
670 for (var i = 0; i < segments.length; i++) {
671 //如果没有参数则返回
672 if (!obj) {
673 return
674 }
675 //将对象中的一个key值 赋值给该对象 相当于 obj = obj[segments[segments.length-1]];
676 obj = obj[segments[i]];
677 }
678 //否则返回一个对象
679 return obj
680 }
681 }
682
683 /* */
684

Callers 1

WatcherFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected