MCPcopy
hub / github.com/layui/layui / get

Function get

src/modules/layer.js:145–158  ·  view source on GitHub ↗
(obj, path, defaultValue)

Source from the content-addressed store, hash-verified

143 * @param {any} defaultValue
144 */
145 var get = function (obj, path, defaultValue) {
146 // 'a[0].b.c' ==> ['a', '0', 'b', 'c']
147 var casePath = path.replace(/\[(\d+)\]/g, '.$1').split('.');
148 var result = obj;
149
150 for (var i = 0; i < casePath.length; i++) {
151 result = result && result[casePath[i]];
152 if (result === null || result === undefined) {
153 return defaultValue;
154 }
155 }
156
157 return result;
158 };
159
160 // 根据给定的键从国际化消息中获取翻译后的内容
161 i18n.$t = function (key) {

Callers 1

layer.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected