Javascript

vue学习-001

本文主要是介绍vue学习-001,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
<!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>{{message}}</h1>
        <h1>{{tags}}</h1>
        <ul>
            <li v-for="tag in tags">{{tag}}</li>
        </ul>
        <h1>{{log}}</h1>
        <button v-on:click="bt1">bt1</button>
        <button @click="log='271'">bt2</button>
    </div>
    <script>
        //全局配置
        const HelloApp = {
            data() { //定义数据
                return {
                    message: 'hello door',
                    tags: ["mid","top","left"],
                    log: ''
                }
            },
            methods: {
                bt1() {
                    this.log='ppts'
                }
            }
        }

        //实例对象
        const app = Vue.createApp(HelloApp).mount('#app')
    </script>
</body>
</html>
这篇关于vue学习-001的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!