vue 手写仿vant2 的goods-action

本文介绍如何使用Vue.js和JavaScript从头开始实现一个仿Vant2的goods-action组件。通过理解组件的设计原理,我们将深入探讨Vue的组件化思想,结合CSS样式实现商品操作栏的布局和交互效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.goods-action {
  box-sizing: border-box;
  width: 100%;
  height: 112px;
  padding: 12px 32px;
  background-color: white;
  display: flex;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  & > div {
    display: flex;
    justify-content: space-between;
    &:first-child > div {
      text-align: center;
      margin: auto 0;
      margin-right: 44px;
      font-size: 20px;
      font-weight: 400;
      color: #303133;
      &:last-child {
        margin-right: 0;
      }
      img {
        width: 44px;
        height: 44px;
        margin-bottom: 4px;
      }
    }
  }
  & > div:last-child {
    margin: auto 0;
    div {
      box-sizing: border-box;
      width: 200px;
      height: 80px;
      text-align: center;
      border: 1px solid #307ef9;
      border-radius: 50px;
      padding: 20px 42px;
      font-size: 28px;
      font-weight: 400;
      color: #307ef9;
      &:last-child {
        background-color: #307ef9;
        color: white;
        margin-left: 16px;
      }
    }
  }
}
<div class="goods-action">
      <div>
        <div @click="call">
          <img src="/images/productDetails/call.png" alt="" />
          <div>电话</div>
        </div>
        <div @click="like">
          <img src="/images/productDetails/like.png" alt="" />
          <div>收藏</div>
        </div>
        <div @click="share">
          <img src="/images/productDetails/share.png" alt="" />
          <div>分享</div>
        </div>
      </div>
      <div>
        <div @click="consult">立即咨询</div>
        <div @click="buy">立即购买</div>
      </div>
    </div>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值