MCPcopy Create free account
hub / github.com/circircir-circle/human_exist_device / getParent

Method getParent

mini_program/common/Tools.js:842–858  ·  view source on GitHub ↗
(parent,name = undefined)

Source from the content-addressed store, hash-verified

840 // 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name
841 // 值(默认为undefined),就是查找最顶层的$parent
842 getParent(parent,name = undefined) {
843 // 通过while历遍,这里主要是为了H5需要多层解析的问题
844 while (parent) {
845 // 父组件
846 if (parent.$options && parent.$options.name !== name) {
847 // 如果组件的name不相等,继续上一级寻找
848 parent = parent.$parent;
849 let tmp = this.getParent(parent,name)
850 if(tmp){
851 return tmp;
852 }
853 } else {
854 return parent;
855 }
856 }
857 return false;
858 }
859
860 os() {
861 return wx.getSystemInfoSync().platform;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected