zoukankan      html  css  js  c++  java
  • Vue 学习第2天 模板——关晓彤

    js

    Vue.component("greeting",{
        template:`
        <p>
            {{name}}:大家好,给大家介绍我的女朋友:关晓彤
            <button v-on:click='changeName'>改名</button>
        </p>
    
    
        `,
        data:function(){
            return{
                name :"鹿晗"
            }
        },
        methods:{
            changeName:function(){
                this.name = "我";
            }
        }
    })
    
    new Vue({
        el:"#vue-app-one"
    });
    
    new Vue({
        el:"#vue-app-two"
    });

    html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>vue.js</title>
        <link rel="stylesheet" type="text/css" href="style.css">
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    
    </head>
    <body>
    
        <div id="vue-app-one">
            <greeting></greeting>
        
    
        </div>
    
    
        <div id="vue-app-two">
            <greeting></greeting>
        
    
        </div>
    </body>
        <script type="text/javascript" src='app.js'></script>
    </html> 

    我:大家好,给大家介绍我的女朋友:关晓彤 改名

    鹿晗:大家好,给大家介绍我的女朋友:关晓彤 改名

  • 相关阅读:
    fedora 27
    Python3 字符串操作
    python3 使用matplotlib画图问题
    Python3 移动文件——合集
    MySQL开放外部链接
    python之csv操作问题
    Question
    17-12-21
    python之List排序
    ubuntu版的sublime-text3输入中文问题
  • 原文地址:https://www.cnblogs.com/polax/p/11371086.html
Copyright © 2011-2022 走看看