首页 > 其他 > 详细

Vue 学习第2天 模板——关晓彤

时间:2019-08-18 09:02:43      阅读:97      评论:0      收藏:0      [点我收藏+]

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> 

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

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

Vue 学习第2天 模板——关晓彤

原文:https://www.cnblogs.com/polax/p/11371086.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!