SOURCE

console 命令行工具 X clear

                    
>
console
Vue.use(VueCompositionAPI);

const { watch, defineComponent, ref, computed } = VueCompositionAPI;

const Component = defineComponent({
    template: '<button @click="addNum">开始死循环</button>',
    setup() {
        const num = ref(1);
        const num2 = ref(2);

        function addNum() {
            num.value++;
        }

        watch(num, () => {
            num2.value++;
            console.log('num changed');
        });

        watch(num2, () => {
            console.log('num2 changed');
        })

        watch(num, () => {
            throw new Error('err');
        });

        return {
            addNum,
        };
    }
})

new Vue({
    el: '#app',
    render: h => h(Component)
});
<div id="app"></div>

本项目引用的自定义外部资源