<script setup>如何使用多个 watch

<script setup>
import { watch, defineProps, reactive } from "vue"

const props = defineProps({
  'nodeId': {
    type: Number,
    required: true,
  },
})

const initState = {
  connectionList: {},
}

const state = reactive(initState);

watch(
  () => props.nodeId,
  (newVal, oldVal)=> {
    console.log('nodeId changed', oldVal, newVal)
  },
)

watch(
  () => state.connectionList,
  (newVal, oldVal)=> {
    console.log('state.connectionNumEchartList changed', oldVal, newVal)
  },
)
</script>

你可能感兴趣的:(前端,vue.js,javascript,前端,setup,watch)