首页 > 其他 > 详细

vue demo

时间:2017-06-30 19:21:29      阅读:331      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="traceur.js"></script>
    <script src="BrowserSystem.js"></script>
    <script src="bootstrap.js"></script>
    <script src="vue.js"></script>
</head>
<script  type="text/traceur">
window.onload=function(){
    Vue.config.devtools = true;
    
    var parent = {
        data(){
            return {
                a:10,
            }
        },
        template: <div @click="pc" >---parent{{a}} -- , <child v-on:increment="incrementTotal" :m.sync="a"></child></div>,
        methods:{
            pc:function(){
                this.a += 0;
            },
            incrementTotal:function(){
                //alert(12344444);
                //this.a = -100;
            },
        },
        components:{
            "child":{
                data(){ // data:function(){  简写
                    return {
                        b:def,
                        c:0,
                    }
                },
                props:[m],
                mounted(){
                    this.c = this.m;
                },
                template:<div @click="cc">child child,<strong>{{typeof m}},{{m}},{{c}},</strong><i>,{{b}},</i></div>,
                methods:{
                    cc:function(){
                        //this.b += 2;
                        this.c += 200;
                        this.m += 100;  //不建议直接操作m,
                        //alert(789);
                        //this.$emit(‘increment‘);
                        //alert(456);
                    }
                },
            }
        }
    }

    var app3 = new Vue({
      el: #app-3,
      data:{
      },
      
      methods:{
      },
      
      components:{
        parent:parent,
      },
      
      computed:{
      }
      
    })
    
};

</script>
<style>
</style>
<body>
<div id="app-3" >
    <parent></parent>==========
</div>
</body>
</html>

 

vue demo

原文:http://www.cnblogs.com/yaowen/p/7100186.html

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