首页 > 其他 > 详细

Vue3.0简单响应式

时间:2021-08-14 15:07:42      阅读:10      评论:0      收藏:0      [点我收藏+]

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>
            hello Vue.js
        </title>
    </head>
    <body>
        <!--View-->
        <div id="app">
            <button @click="increment">
                count值:{{state.count}}
            </button>
        </div>

        <!--引入Vue.js-->
        <script src="https://unpkg.com/vue@next"></script>
        <script>
            const App={
                setup(){
                    //为目标对象创建一个响应式对象
                    const state = Vue.reactive({count: 0});
                    function increment(){
                        state.count++;
                    }
                    return {
                        state,
                        increment
                    }
                }
            };

            //创建应用程序实例,该实例提供应用程序上下文
            //应用程序实例装载的整个组件树将共享相同的上下文
            const app = Vue.createApp(App);
            app.mount(#app);
        </script>
    </body>
</html>

 

Vue3.0简单响应式

原文:https://www.cnblogs.com/mingforyou/p/15140616.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!