Vue3.0基于Proxy 实现的数据更变检测 支持Composition API和Options API,以及typings

Composition API 纯函数式 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app"></div>
<script src="vue.global.js"></script>
<script>
    // Composition API
    const App = {
        setup () {
            let state = Vue.reactive({name: ‘wyq‘, age: 18});
            const other = function () {
                console.log(‘111‘);
                state.name = ‘点击了‘
            };
            Vue.onMounted(() => {
                console.log(‘dom加载完了‘)
            });
            Vue.effect(() => {
                console.log(state.name)
            })
            return {
                state,
                other
            }
        },
        template: `<div @click="other">{{state.name}}</div>`,
    }
    Vue.createApp().mount(App, app)
</script>
</body>
</html>

  ts实现类型推断 函数式编程 响应式才是核心

Vue3.0基于Proxy 实现的数据更变检测 支持Composition API和Options API,以及typings

上一篇:PHP SPL被遗落的宝石


下一篇:史上无敌,1941个网站模版,终生收藏