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> 

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

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

  • 相关阅读:
    less中遇到的一些特殊的写法
    观察者模式
    发布订阅模式
    javascript中的函数
    关于js中this的理解和作用
    [Oracle]Oracle镜像安装及使用教程
    log4net日志配置
    过滤器
    .net core 处理 中文乱码
    Fromform
  • 原文地址:https://www.cnblogs.com/polax/p/11371086.html
Copyright © 2011-2022 走看看