美文网首页
Vue下的components模板间的数据流

Vue下的components模板间的数据流

作者: 追key | 来源:发表于2018-04-17 22:25 被阅读0次

Vue下的components模板间的数据流,

晴 微风 温度 12-24°C
在我们越来越深入Vue时,我们会发现我们对HTML代码的工程量会越来越少,今天我们来谈谈Vue下的 components模板的 初步使用方法与 应用

我们先来简单的写一段vue代码

        <div id="app">
        父亲{{money}}
        <child :m="money"></child>
    </div>
        
      //创建 child 模板
      let child = {
        //模板内容:   儿子  +  m(data.money)  + button按钮
        template:"<div>儿子{{m}}<button>按钮</button><div>"
        
        //传递的数据的一些配置
        props:{
               "m":{
                 // 这里的数据类型有[String,Number,Object,Array]
                  type:Number,
                  required:ture
              }
        },
        methods:{
                //接收数据
                getMore(){
                      this.m=666;
                }
        }  
      }

    
      //实例化出 对象
      let vm = new Vue({
        el:"#app",
        data:{
          money:400
        },
        compoents:{
          child
        }

    });

相关文章

网友评论

      本文标题:Vue下的components模板间的数据流

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