(val, shallow = false)
| 940 | _value; |
| 941 | value; |
| 942 | constructor(val, shallow = false) { |
| 943 | const _this = this; |
| 944 | this._isShallow = shallow; |
| 945 | if (val && typeof val === 'object' && shallow) { |
| 946 | const reactiveVal = reactive(val); |
| 947 | this._value = reactiveVal; |
| 948 | this.value = reactiveVal; |
| 949 | } |
| 950 | else { |
| 951 | this._value = val; |
| 952 | this.value = val; |
| 953 | } |
| 954 | // 定义属性 |
| 955 | Object.defineProperty(this, 'value', { |
| 956 | get() { |
| 957 | // 收集依赖 |
| 958 | trackRef(this); |
| 959 | return _this._value; |
| 960 | }, |
| 961 | set(newVal) { |
| 962 | // 旧数据 |
| 963 | const oldVal = this._value; |
| 964 | // 数据变化 |
| 965 | if (oldVal !== newVal) { |
| 966 | // 设置新数据值 |
| 967 | _this._value = newVal; |
| 968 | // 通知依赖 |
| 969 | triggerRef(this, newVal, oldVal); |
| 970 | } |
| 971 | }, |
| 972 | }); |
| 973 | } |
| 974 | toJSON() { |
| 975 | return this._value; |
| 976 | } |
nothing calls this directly
no test coverage detected