vue 基础

 声明式渲染

类似C#里的 $'' 字符串插值

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue测试</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="counter">
        Counter: {{ counter }}
    </div>
    <script>
        const Counter = {
            //
            data() {
                return {
                    counter: 0
                }
            },
            //
            mounted() {
                setInterval(() => {
                    this.counter++
                }, 1000)
            }
        }
        //console.log(typeof Counter.data().counter)
        Vue.createApp(Counter).mount('#counter')
    </script>
</body>
</html>

此变量是响应式的

组件定义

根组件

 

原文地址:https://www.cnblogs.com/buchizaodian/p/14879647.html