如何在下列代码中将SwipeCell组件放在van-card组件内部,并将删除按钮放在SwipeCell组件的right slot中,商品信息放在SwipeCell组件的default slot中。组件van-card代码如下:——index.json——{ "component": true, "usingComponents": { "van-card": "@vant/weapp/card/index", "van-stepper": "@vant/weapp/stepper/index", "van-swipe-cell": "@vant/weapp/swipe-cell/index" } } ——wxml——<view class="goods-card"> <radio disabled="{{ goodsData.amount <= 0 }}" bind:tap="changeChecked" class="goods-card-radio" checked="{{ goodsData.amount <= 0 ? false : goodsData.checked }}" color="#ff6034" /> <van-card custom-class="flo-goods-card" style="flex: 1; height:calc(42vh - 50px)" tag="{{ goodsData.amount > 0 ? '' : '售磬' }}" price="{{ goodsData.price || '' }}" title="{{ goodsData.title || '' }}" thumb="{{ goodsData.showPictures || '' }}"> <view slot="num"> <van-stepper disabled="{{ goodsData.amount <= 0 }}" style="position: absolute; right: 0rpx; top: 75%;" input-width="42rpx" button-size="45rpx" theme="round" bind:change="changeValue" value="{{ goodsData.value }}" step="1" /> </view> </van-card> </view>
时间: 2023-07-05 14:12:17 浏览: 181
你可以在van-card组件内部添加van-swipe-cell组件,并将商品信息放在SwipeCell组件的default slot中,将删除按钮放在SwipeCell组件的right slot中。代码如下:
```
<view class="goods-card">
<radio disabled="{{ goodsData.amount <= 0 }}" bind:tap="changeChecked" class="goods-card-radio" checked="{{ goodsData.amount <= 0 ? false : goodsData.checked }}" color="#ff6034" />
<van-card custom-class="flo-goods-card" style="flex: 1; height:calc(42vh - 50px)" tag="{{ goodsData.amount > 0 ? '' : '售磬' }}" price="{{ goodsData.price || '' }}" title="{{ goodsData.title || '' }}" thumb="{{ goodsData.showPictures || '' }}">
<van-swipe-cell right-width="65rpx">
<view slot="default">
<!-- 商品信息 -->
</view>
<view slot="right">
<!-- 删除按钮 -->
</view>
</van-swipe-cell>
<view slot="num">
<van-stepper disabled="{{ goodsData.amount <= 0 }}" style="position: absolute; right: 0rpx; top: 75%;" input-width="42rpx" button-size="45rpx" theme="round" bind:change="changeValue" value="{{ goodsData.value }}" step="1" />
</view>
</van-card>
</view>
```
阅读全文