封装轮播图组件

父组件

<template>
  <div id="app">
    <!--first></first-->
    <banner :list="list"
            :looptime="looptime"
            :width="width"
            :height="height"
            :background="background"
            :color="color"
            :fontSize="fontSize"
            @prev="prev"
            @next="next"
            @change="changeBanner"
            @click="bannerClick">
    </banner>
    <!-- footer>Footer</footer -->
  </div>
</template>

<script>
import banner from './banner'
export default {
  name: 'App',
  data () {
    return {
      looptime: 4000, // 循环时间
      width: 400,
      height: 200,
      background: 'red',
      color: '#fff',
      fontSize: '70px',
      list: [
        {
          id: 1,
          text: '1',
          url: 'http1'
        },
        {
          id: 2,
          text: '2',
          url: 'http2'
        },
        {
          id: 3,
          text: '3',
          url: 'http3'
        },
        {
          id: 4,
          text: '4',
          url: 'http4'
        }
      ]
    }
  },
  created () {},
  methods: {
    // 点击下一页回调
    prev (index, list) {
      // console.log('我点击了上一页')
      // console.log(index)
      // console.table(list)
    },
    // 点击下一页回调
    next () {
      // console.log('我点击了下一页')
      // console.log(index)
      // console.table(list)
    },
    // 鼠标移入状态点回调
    changeBanner (index) {
      // console.log('我移入了鼠标状态点了')
      // console.log(index)
    },
    bannerClick (index, item) {
      // console.log('我点击了广告内容')
      // console.log(index)
      // console.table(item)
    }
  },
  computed: {},
  components: {
    banner
  }
}
</script>

<style lang="less" scoped>
// * {
//   margin: 0;
//   padding: 0;
//   font-family: '微软雅黑';
// }
// li {
//   list-style: none;
// }
// body {
//   padding: 100px 0;
// }
// header,
// footer {
//   position: fixed;
//   height: 100px;
//   width: 100%;
//   background: blue;
//   font-size: 30px;
//   color: #fff;
//   line-height: 100px;
//   text-align: center;
// }
// footer {
//   bottom: 0;
// }
// header {
//   top: 0;
// }
</style>

子组件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值