(data, type, isEdit, result = '')
| 664 | return data; |
| 665 | }, |
| 666 | objectUrlEval(data, type, isEdit, result = '') { |
| 667 | // 此方法的用法: |
| 668 | // 若存在 此数据结构的数据 ps: a: { b: c: { d: { name: 'xx'}} } |
| 669 | // 调用此方法仅需 objectUrlEval(a, 'b.c.d.name',false) 即可返回 'xx' |
| 670 | // 若 objectUrlEval(a, 'b.c.d.name',true, 'yy') 可修改name的值为 'yy' |
| 671 | // 第一个参数是数据源 第二个参数是对象的路径 第三个若传则为此路径赋值 |
| 672 | if (data !== undefined) { |
| 673 | const temp = type.split('.'); |
| 674 | const tempLength = temp.length; // 路径的长度 |
| 675 | let tempA = data; |
| 676 | for (let i = 0; i < tempLength; i++) { |
| 677 | if (i === tempLength - 1) { |
| 678 | if (isEdit) { |
| 679 | // tempA[temp[i]] = result // 赋值 |
| 680 | // 如果想要监听数组变化用set |
| 681 | this.$set(tempA, temp[i], result); |
| 682 | break; |
| 683 | } else { |
| 684 | // if (typeof tempA[temp[i]] === 'object') { |
| 685 | // return JSON.stringify(tempA[temp[i]]) |
| 686 | // } else { |
| 687 | return tempA[temp[i]]; // 获取值返回 |
| 688 | // } |
| 689 | } |
| 690 | } |
| 691 | if (typeof tempA[temp[i]] === 'object') { |
| 692 | tempA = tempA[temp[i]]; |
| 693 | continue; |
| 694 | } else { |
| 695 | tempA[temp[i]] = {} // 不是对象则新增 |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | }, |
| 700 | addStr(oldStr, addItem, afterWhich) { |
| 701 | // 在指定字符串后面添加指定字符串 |
| 702 | const strArr = oldStr.split(''); |
nothing calls this directly
no outgoing calls
no test coverage detected