vue学习-005

<!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>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>{{name}}</h1>
        <h1>{{name}}</h1>
        <h1>{{names()}}</h1>
        <h1>{{names()}}</h1>
    </div>
    <script>
        const app = Vue.createApp({
                data() {
                    return {
                        b: 'front',
                        s: 'back'
                    }
                },
                computed: {
                    name() {
                        console.log("computed");
                        return this.b + ' ' + this.s
                    }
                },
                methods: {
                    names() {
                        console.log("methods");
                        return this.b + ' ' + this.s
                    }
                }
            }).mount('#app')
    </script>
</body>
</html>
posted @ 2021-11-18 15:03  昵称要矢  阅读(40)  评论(0)    收藏  举报