English
Add product to cart, buy now
<template>
<uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
</template>
<script>
export default {
data () {
return {
options: [{
icon: 'headphones',
}, {
icon: 'shop',
info: 2,
infoBackgroundColor:'#007aff',
infoColor:"red"
}, {
icon: 'cart',
info: 2
}],
buttonGroup: [{
backgroundColor: '#ff0000',
color: '#fff'
},
{
backgroundColor: '#ffa200',
color: '#fff'
}
]
}
},
methods: {
onClick (e) {
uni.showToast({
icon: 'none'
})
},
buttonClick (e) {
console.log(e)
this.options[2].info++
}
}
}
</script>
| property name | type | default value | description |
|---|---|---|---|
| options | Array | - | Component Parameters |
| buttonGroup | Array | - | Component button group parameters |
| fill | Boolean | false | Whether the button is tiled |
options parameter description:
| property name | type | default value | description |
|---|---|---|---|
| text | String | - | Display text |
| icon | String | icon, reference | |
| info | Number | 0 | Number in the upper right corner |
| infoBackgroundColor | String | #ff0000 | Corner background color |
| infoColor | String | #fff | Corner Foreground Color |
buttonGroup parameter description:
| property name | type | default value | description |
|---|---|---|---|
| text | String | - | Button Text |
| backgroundColor | String | - | Button background color |
| color | String | - | Font Color |
| Event Name | Description | Return Value |
|---|---|---|
| @click | left click event | e = {index,content} |
| @buttonClick | Right button group click event | e = {index,content} |
attention
The example relies on multiple components such as uni-card uni-section uni-scss, copying the example code directly will not work properly.
Please go to the Component download page , select Import sample project using HBuilderX on the right side of the page to experience the complete component example.
Template
Script
Style
<template>
<view class="uni-container">
<uni-card is-full>
<text class="uni-h6"> uni-goods-nav 组件主要用于电商类应用底部导航,可自定义加入购物车,购买等操作</text>
</uni-card>
<uni-goods-nav @click="onClick" />
</uni-section>
<uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup" @click="onClick"
@buttonClick="buttonClick" />
<uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup1" @click="onClick"
@buttonClick="buttonClick" style="margin-top: 20px;" />
</uni-section>
<view class="goods-carts">
<uni-goods-nav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick"
@buttonClick="buttonClick" />
</view>
</view>
</template>