前端高阶1 - Vue3 + TS - 8-to系列全家桶 - toRef

77 阅读1分钟
  • toRef

    • 如果原始对象是非响应式的就不会更新视图 数据是会变的
    • 实例:

      • let obj = reactive({foo: 1,bar: 1})
      • const state = toRef(obj, 'bar') // bar 转化为响应式对象
      • const change = () => {

        • state.value++
        • console.log(obj, state);
      • }