(obj, path, defaultValue)
| 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) { |