zoukankan      html  css  js  c++  java
  • vue-cli4脚手架搭建三

    组件传值

    <script>
        import LunBo from "./LunBo";
    
    export default {
      name: 'Home',
        components: {LunBo},
        data(){
        return {
    
          lists:[
            {title:'标题1',color:'#ffbb78'},
            {title:'标题2',color:'#b5cf6b'},
            {title:'标题3',color:'#4169e1'}
          ],
            imgArr:[
                require('../assets/img/gu.png') ,
                require('../assets/img/jian.png') ,
                require('../assets/img/monitor.png')
            ]
        }
      }
    }
    </script>
    <LunBo :imgArr="imgArr"></LunBo>

    组件中props接收值

    数组定义方式

    props:["imgArr"],
    mounted:function () { //页面加载后,自动执行函数
    this.play();
    },
    destroyed:function () {
    clearInterval(this.imageTimer);
    }

    对象方式

    
    
    props:{
    imgArr:{},
    },
    mounted:function () { //页面加载后,自动执行函数
    this.play();
    },
    destroyed:function () {
    clearInterval(this.imageTimer);
    }
    
    
    student1:{
    id:1,
    name:'zhangsan',
    age:15
    }
    <label> {{student.id}} -- {{student.name}} -- {{student.age}}</label>
    props:{
        imgArr:{},
        student: {
            id:Number,
            name:String,
            age:Number
        }
        },
  • 相关阅读:
    LightOJ
    Peter and Snow Blower
    Gena's Code
    nyoj139--我排第几个 (康拓展开)
    hdoj1394(归并排序)
    树状数组
    Poj 1113--Wall(凸集)
    hdoj1437 -- 天气情况
    hdoj1428 -- 漫步校园 (记忆化搜索)
    图像边缘检测
  • 原文地址:https://www.cnblogs.com/perfei/p/13339170.html
Copyright © 2011-2022 走看看