1.数组
ref
const array = ref([1,2,3]);
watch(array,()=>{
console.log(array.value);
},)
array.value = [];
array.value.length = 0
slice
const array = ref([1,2,3]);
watch(array,()=>{
console.log(array.value);
},)
array.value = array.value.slice(0,0);
reactive
const array = reactive([1,2,3]);
watch(()=>[...array],()=>{
console.log(array);
},)
array.length = 0;
2.对象
cosnt obj = reactive({
a:1
})
let ob = {
a:2,
c:3
}
Object.assign(obj,ob)