Vue仿京东左侧列表划过显示 组件

<template>
  <q-page class="flex_classifycation">
    <div class="tabwrapper" @mouseleave="handleleave">
      <div class="left">
        <ul>
          <li
            v-for="(item, index) of citylist"
            :key="index"
            @mouseenter="handleenter(index)"
            :class="{
              active: currentindex == index,
            }"
          >
            <span>{{ item.type }}</span
            ><i></i>
          </li>
        </ul>
      </div>
      <div class="right" v-if="isshow">
        <ul>
          <li v-for="(v, i) of citylist[currentindex].children" :key="i">
            <strong>{{ i + 1 }}</strong>
            <span>{{ v.city }}</span>
            <i>{{ v.desc }}</i>
          </li>
        </ul>
      </div>
    </div>
  </q-page>
</template>

<script>
export default {
  name: "ClassificationMain",
  data: function () {
    return {
      isshow: false,
      currentindex: 99,
      citylist:  [
        {
          "type": "热门城市",
          "children": [
            {
              "city": "北京",
              "desc": "世界著名古都和现代化国际城市"
            },
            {
              "city": "广州",
              "desc": "粤港澳大湾区、泛珠江三角洲经济区"
            },
            {
              "city": "上海",
              "desc": "长江入海口,东隔东中国海"
            },
            {
              "city": "成都",
              "desc": "国家历史文化名城"
            },
            {
              "city": "西安",
              "desc": "中国国际形象最佳城市之一"
            }
          ]
        },
        {
          "type": "推荐城市",
          "children": [
            {
              "city": "青岛",
              "desc": "滨海度假旅游城市"
            },
            {
              "city": "杭州",
              "desc": "西湖十景"
            },
            {
              "city": "深圳",
              "desc": "世界影响力的创新创意之都"
            },
            {
              "city": "广州",
              "desc": "粤港澳大湾区、泛珠江三角洲经济区"
            },
            {
              "city": "成都",
              "desc": "国家历史文化名城"
            }
          ]
        },
        {
          "type": "奔向海岛",
          "children": [
            {
              "city": "秦皇岛",
              "desc": "驰名中外的旅游休闲胜地"
            },
            {
              "city": "青岛",
              "desc": "滨海度假旅游城市"
            },
            {
              "city": "珠海",
              "desc": "浪漫之城,百岛之市"
            },
            {
              "city": "深圳",
              "desc": "世界影响力的创新创意之都"
            },
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            }
          ]
        },
        {
          "type": "主题推荐",
          "children": [
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            },
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            },
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            },
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            },
            {
              "city": "海口",
              "desc": "海滨自然旖旎风光"
            },
            {
              "city": "广州",
              "desc": "粤港澳大湾区、泛珠江三角洲经济区"
            },
            {
              "city": "上海",
              "desc": "长江入海口,东隔东中国海"
            },
            {
              "city": "珠海",
              "desc": "浪漫之城,百岛之市"
            },
            {
              "city": "西安",
              "desc": "中国国际形象最佳城市之一"
            }
          ]
        }
      ]
    };
  },
  created: function () {
    this.getcity();
  },
  methods: {
    handleenter: function (index) {
      this.currentindex = index;
      this.isshow = true;
    },
    handleleave: function () {
      this.currentindex = 99;
      this.isshow = false;
    },
    getcity: function () {
      this.$axios({
        url: "/posts/cities",
      }).then((res) => {
        // console.log(res.data);
        // this.citylist = res.data.data;
      });
    },
  },
}
</script>

<style lang="scss" scoped>
*{
  margin: 0;
  padding: 0;
}
.flex_classifycation{

  min-height: 480px !important;
}
.tabwrapper {
  box-sizing: border-box;
  position: relative;
  width: 1200px;
  height: 480px;
  .left {
    position: relative;
    box-sizing: border-box;
    width: 190px;
    height: 480px;
    background: #fff;
    border-right: none;
    border-bottom: none;
    z-index: 2;
    ul > li {
      box-sizing: border-box;
      width: 190px;
      height: 41px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      //border-right: 1px solid #999;
      border-bottom: 1px solid #eee;
      padding-left: 20px;
      &.active {
        border-right-color: #fff;
        color: brown;
        i {
          border-color: #999999;
        }
      }
      // &:hover {
      // color: orange;
      // border-right-color: #fff;
      //   i {
      //     border-color: orange;
      //   }
      // }
      //i {
      //  width: 14px;
      //  height: 14px;
      //  border-top: 1px solid #999;
      //  border-right: 1px solid #999;
      //  transform: rotate(45deg);
      //}
    }
    li:hover{
      background: #eee;
      color: brown;
    }
  }
  .right {
    box-sizing: border-box;
    position: absolute;
    top: 0;
    width: 1010px;
    min-height: 480px;
    left: 190px;
    border: 1px #eee solid;

    ul > li {
      width: 360px;
      height: 42px;
      display: flex;
      align-items: center;
      strong {
        display: inline-block;
        margin-left: 20px;
        color: black;
      }
      span {
        display: inline-block;
        margin-left: 20px;
        color: black;
      }
      i {
        display: inline-block;
        margin-left: 20px;
      }
    }
  }
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于vue仿京东商城前端页面的开发,你可以按照以下步骤进行: 1. 创建Vue项目:使用Vue CLI来创建一个新的Vue项目,可以通过命令行运行`vue create my-project`来初始化一个新项目。 2. 设计页面结构:根据京东商城的页面需求,设计并创建对应的组件。可以将页面拆分成多个可复用的组件,例如顶部导航栏、轮播图、商品列表等。 3. 使用Vue Router实现路由:通过Vue Router创建路由,定义页面之间的跳转关系。根据京东商城的不同页面,设置对应的路由路径。 4. 数据管理:使用Vuex来管理应用的状态和数据。根据需要,可以定义不同的模块来管理不同的状态,例如用户信息、购物车等。 5. 调用API接口:通过Axios或其他HTTP库来调用后端API接口获取数据。根据京东商城的需求,调用相应的API接口获取商品信息、用户信息等。 6. 渲染页面:将获取到的数据渲染到对应的组件中,展示在页面上。使用Vue的数据绑定和指令来动态显示数据和响应用户操作。 7. 样式设计:使用CSS或CSS预处理器(如Sass、Less)来设计样式,并进行页面布局和美化。根据京东商城页面的样式要求,进行相应设计。 8. 响应式设计:使用Vue的响应式特性,使页面能够适应不同的设备和屏幕尺寸。可以使用Vue的响应式布局、媒体查询等技术来实现。 9. 页面优化:对页面进行性能优化,如代码压缩、图片懒加载、路由懒加载等,提升用户体验和网页加载速度。 10. 测试和部署:通过单元测试和集成测试对应用进行测试,确保功能和页面的正常运行。最后将项目打包并部署到服务器上供用户访问。 以上是一个简单的开发流程,具体的实现会根据你的具体需求和技术栈而有所差异。希望能对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值