html网站开发实例视频,建设部网站79号文件,重庆市娱乐场所暂停营业,可以做app的网站有哪些Vue3-shallowRef 和 shallowReactive函数#xff08;浅层次的响应式#xff09;
shallowRef函数
功能#xff1a;只给基本数据类型添加响应式。如果是对象#xff0c;则不会支持响应式#xff0c;层成也不会创建Proxy对象。ref和shallowRef在基本数据类型上是没有区别的…Vue3-shallowRef 和 shallowReactive函数浅层次的响应式
shallowRef函数
功能只给基本数据类型添加响应式。如果是对象则不会支持响应式层成也不会创建Proxy对象。ref和shallowRef在基本数据类型上是没有区别的shallowRef函数主要作用于不进行修改对象中的属性。 templateh2计数器1{{data.counter1}}/h2button clickdata.counter1计数器1加1/button
/templatescript setupimport { shallowRef } from vuelet data shallowRef({counter1 : 1})console.log(data);
/scriptshallowReactive函数
功能shallowReactive 对象中只有第一层支持响应式之后的都不支持响应式。 templateh2计数器1{{data.counter1}}/h2button clickdata.counter1计数器1加1/buttonhrh2计数器2{{data.a.counter2}}/h2button clickdata.a.counter2计数器2加1/button
/templatescript setupimport { shallowReactive } from vuelet data shallowReactive({counter1 : 1,a : {counter2 : 100}})
/scriptcounter2 : 100}})
/script