美文网首页
vue.js component

vue.js component

作者: ZhouJiping | 来源:发表于2016-05-28 11:55 被阅读327次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue js</title>
</head>
<body>
    <div id="app">
        <counter heading="Likes" color="green"></counter>
        <counter heading="DisLikes" color="red"></counter>
    </div>

    <template id="counter-templete">
        <h1>{{ heading }}</h1>
        <button @click="count += 1" style="background: {{ color  }}">{{count}}</button>
    </template>
    <script src="vue.js"></script>
    <script>
        Vue.component('counter', {
            template:'#counter-templete',
            props:['heading', 'color'],
            data : function () {
                return { count : 0};
            }
        });
        new Vue({
            el: "#app"
        });
    </script>
</body>
</html>

相关文章

网友评论

      本文标题:vue.js component

      本文链接:https://www.haomeiwen.com/subject/oevfdttx.html