记个踩坑笔记
<template>
{{list}}
<button @click="add">增加</button>
<button @click="clearAll">清空</button>
{{newList}}
</template>
<script>
import { ref, watch, toRefs,computed,reactive,onBeforeUpdate,onUpdated,onBeforeMount,onMounted,onBeforeUnmount,onUnmounted ,onRenderTracked,onRenderTriggered } from 'vue'
export default {
name: '',
components: {
setup(){
let list = ref([])
function add(){
list.value.push(123)
state.newList.push(123)
let state = reactive({
newList:[]
function clearAll(){
list.value = [1,2,3,4,5]
// list.length = 0
state.newList = []
console.log(list)
return {
list,
clearAll,
...toRefs(state)