• Vue2.5 旅游项目实例6 首页-推荐区域组件


    还是在远程创建分支 :index-recommend

    拉到本地并切换分支:

    git pull
    git checkout index-recommend

    在homecomponents目录下新建Icons.vue文件,

    然后在Home.vue文件中引用:

    <template>
    <div>
      <home-header></home-header>
      <home-swiper></home-swiper>
      <home-icons></home-icons>
      <home-recommend></home-recommend>
    </div>
    </template>
    
    <script>
    import HomeHeader from './components/Header'
    import HomeSwiper from './components/Swiper'
    import HomeIcons from './components/Icons'
    import HomeRecommend from './components/Recommend'
    export default {
      name: 'Home',
      components: {
        HomeHeader,
        HomeSwiper,
        HomeIcons,
        HomeRecommend
      },
      data () {
        return {
        }
      }
    }
    </script>

    在Icons.vue中添加样式:

    .icons >>> .swiper-containter
       100%
      height:0
      padding-bottom: 50%
    .icons
      margin-top: .1rem

    继续编辑Recommend.vue文件:

    <template>
    <div>
      <div class="title">热销推荐</div>
      <ul>
        <li class="item border-bottom">
          <img class="item-img" src="https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_200x200_2458ffb2.jpg" alt="" />
          <div class="item-info">
            <p class="item-title">北京-东京 5天跟团游</p>
            <p class="item-desc">欢乐畅想 东京+横滨+富士山+镰仓+江之岛神社</p>
            <button class="item-button">查看详情</button>
          </div>
        </li>
      </ul>
    </div>
    </template>
    
    <script>
    export default {
      name: 'HomeRecommend',
      data () {
        return {
        }
      }
    }
    </script>
    
    <style lang="stylus" scoped>
    @import '~styles/mixins.styl'
    .title
      margin-top: .2rem
      line-height: .8rem
      background: #eee
      text-indent: .2rem
    .item
      display:flex
      height: 1.9rem
      overflow: hidden
      .item-img
        width :1.7rem
        height 1.7rem
        padding:.1rem
      .item-info
        flex: 1
        padding:.1rem
        min- 0  // 子集的文字超出隐藏
        .item-title
          line-height:.54rem
          font-size: .32rem
          ellipsis()
        .item-desc
          line-height:.4rem
          font-size: .28rem
          color:#ccc
          ellipsis()
        .item-button
          line-height: .44rem
          margin-top: .16rem
          background: #ff9300
          color: #fff
          padding: 0 .2rem
          border-radius: .06rem
    </style>

    此时可以显示一条推荐信息,下面开始定义循环:

    <template>
    <div>
      <div class="title">热销推荐</div>
      <ul>
        <li class="item border-bottom" v-for="item in recommendList" :key="item.id">
          <img class="item-img" :src="item.imgUrl" alt="" />
          <div class="item-info">
            <p class="item-title">{{item.title}}</p>
            <p class="item-desc">{{item.desc}}</p>
            <button class="item-button">查看详情</button>
          </div>
        </li>
      </ul>
    </div>
    </template>
    <script>
    export default {
      name: 'HomeRecommend',
      data () {
        return {
          recommendList: [
            {
              id: '0001',
              imgUrl: 'https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_200x200_2458ffb2.jpg',
              title: '北京-东京 5天跟团游',
              desc: '欢乐畅想 东京+横滨+富士山+镰仓+江之岛神社'
            },
            {
              id: '0002',
              imgUrl: 'https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_200x200_2458ffb2.jpg',
              title: '尼泊尔9晚10天',
              desc: '悬崖酒店+超视觉两大歌舞+京津冀免费联运+骑大象'
            },
            {
              id: '0003',
              imgUrl: 'https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_200x200_2458ffb2.jpg',
              title: '【家庭游】升级碧桂园',
              desc: '张家界国家森林公园天门山玻璃桥凤凰双飞6日丨赠魅力湘西'
            }
          ]
        }
      }
    }
    </script>

    效果图:

  • 相关阅读:
    Cpp Singleton
    回溯法( Backtracking Algorithms ) :C语言Maze迷宫问题(自己实现)
    First wxWidgets Demo, wxWidgets简单示例
    copy contructor拷贝构造函数 (Copy Control)
    UPX (Ultimate Packer for eXecutables) 多平台可执行文件压缩
    wxWidgets Event Handling
    WxWidgets 安装与测试
    顺序查找 sequential find
    HDU1171 Big Event in HDU 背包
    HDU2091 水题
  • 原文地址:https://www.cnblogs.com/joe235/p/12467750.html
Copyright © 2020-2023  润新知