# Sku
### Install
```js
import Vue from 'vue';
import { Sku } from 'vant';
Vue.use(Sku);
```
## Usage
### Basic Usage
```html
<van-sku
v-model="show"
:sku="sku"
:goods="goods"
:goods-id="goodsId"
:hide-stock="sku.hide_stock"
:quota="quota"
:quota-used="quotaUsed"
:reset-stepper-on-hide="resetStepperOnHide"
:reset-selected-sku-on-hide="resetSelectedSkuOnHide"
:disable-stepper-input="disableStepperInput"
:message-config="messageConfig"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
/>
```
```js
export default {
data() {
return {
show: false,
sku: {},
goods: {},
messageConfig: {},
};
},
};
```
### Custom Stepper
```html
<van-sku
v-model="show"
:sku="sku"
:goods="goods"
:goods-id="goodsId"
:hide-stock="sku.hide_stock"
:quota="quota"
:quota-used="quotaUsed"
:custom-stepper-config="customStepperConfig"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
/>
```
### Custom By Slot
```html
<van-sku
v-model="show"
stepper-title="Stepper title"
:sku="sku"
:goods="goods"
:goods-id="goodsId"
:hide-stock="sku.hide_stock"
:quota="quota"
:quota-used="quotaUsed"
show-add-cart-btn
reset-stepper-on-hide
:initial-sku="initialSku"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
>
<!-- custom sku-header-price -->
<template #sku-header-price="props">
<div class="van-sku__goods-price">
<span class="van-sku__price-symbol">¥</span
><span class="van-sku__price-num">{{ props.price }}</span>
</div>
</template>
<!-- custom sku actions -->
<template #sku-actions="props">
<div class="van-sku-actions">
<van-button square size="large" type="warning" @click="onPointClicked">
Button
</van-button>
<!-- trigger sku inner event -->
<van-button
square
size="large"
type="danger"
@click="props.skuEventBus.$emit('sku:buy')"
>
Button
</van-button>
</div>
</template>
</van-sku>
```
## API
### Props
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| v-model | Whether to show sku | _boolean_ | `false` |
| sku | Sku data | _object_ | - |
| goods | Goods info | _object_ | - |
| goods-id | Goods id | `string | _number_ | - |
| price-tag | Tag behind the price | _string_ | - |
| hide-stock | Whether to hide stock | _boolean_ | `false` |
| hide-quota-text | Whether to hide quota text | _boolean_ | `false` |
| hide-selected-text | Whether to hide selected text | _boolean_ | `false` |
| stock-threshold | stock threshold | _boolean_ | `50` |
| show-add-cart-btn | Whether to show cart button | _boolean_ | `true` |
| buy-text | Buy button text | _string_ | - | - |
| add-cart-text | Add cart button text | _string_ | - | - |
| quota | Quota (0 as no limit) | _number_ | `0` |
| quota-used | Used quota | _number_ | `0` |
| reset-stepper-on-hide | Whether to reset stepper when hide | _boolean_ | `false` |
| reset-selected-sku-on-hide | Whether to reset selected sku when hide | _boolean_ | `false` |
| disable-stepper-input | Whether to disable stepper input | _boolean_ | `false` |
| close-on-click-overlay | Whether to close sku popup when overlay is clicked | _boolean_ | `true` |
| stepper-title | Quantity title | _string_ | `Quantity` |
| custom-stepper-config | Custom stepper related config | _object_ | `{}` |
| message-config | Message related config | _object_ | `{}` |
| disable-soldout-sku `v2.11.3` | Whether to disable soldout sku | _boolean_ | `true` |
| get-container | Return the mount node for sku | _string \| () => Element_ | - |
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
| start-sale-num `v2.3.0` | Minimum quantity | _number_ | `1` |
| properties `v2.4.2` | Goods properties | _array_ | - |
| preview-on-click-image `v2.5.2` | Whether to preview image when click goods image | _boolean_ | `true` |
| show-header-image `v2.9.0` | Whether to display header image | _boolean_ | `true` |
| lazy-load | Whether to enable lazy load,should register [Lazyload](#/en-US/lazyload) component | _boolean_ | `false` |
### Events
| Event | Description | Arguments |
| --- | --- | --- |
| add-cart | Emitted when click cart button | data: object |
| buy-clicked | Emitted when click buy button | data: object |
| stepper-change | Emitted when stepper value changed | value: number |
| sku-selected | Emitted when select sku | { skuValue, selectedSku, selectedSkuComb } |
| sku-prop-selected | Emitted when select property | { propValue, selectedProp, selectedSkuComb } |
| open-preview | Emitted when open image preview | data: object |
| close-preview | Emitted when close image preview | data: object |
| sku-reset `v2.8.1` | Emitted when reset sku and property | { selectedSku, selectedProp, selectedSkuComb } |
### Methods
Use [ref](https://vuejs.org/v2/api/#ref) to get Sku instance and call instance methods.
| Name | Description | Attribute | Return value |
| --- | --- | --- | --- |
| getSkuData | Get current skuData | - | skuData |
| resetSelectedSku `v2.3.0` | Reset selected sku to initial sku | - | - |
### Slots
| Name | Description |
| ------------------------------- | --------------------------------- |
| sku-header | Custom header |
| sku-header-price | Custom header price area |
| sku-header-origin-price | Custom header origin price area |
| sku-header-extra | Extra header area |
| sku-header-image-extra `v2.5.2` | Custom header image extra area |
| sku-body-top | Custom content before sku-group |
| sku-group | Custom sku |
| extra-sku-group | Extra custom content |
| sku-stepper | Custom stepper |
| sku-messages | Custom messages |
| sku-actions-top `v2.4.7` | Custom content before sku-actions |
| sku-actions | Custom button actions |
### Sku Data Structure
```js
sku: {
tree: [
{
k: 'Color',
k_s: 's1',
v: [
{
id: '1',
name: 'Red',
imgUrl: 'http://222.178.203.72:19005/whst/63/=hlfzxybcmzbm//1.jpg',
previewImgUrl: 'http://222.178.203.72:19005/whst/63/=hlfzxybcmzbm//1p.jpg',
},
{
id: '1',
name: 'Blue',
imgUrl: 'http://222.178.203.72:19005/whst/63/=hlfzxybcmzbm//2.jpg',
previewImgUrl: 'http://222.178.203.72:19005/whst/63/=hlfzxybcmzbm//2p.jpg',
}
],
largeImageMode: true, // whether to enable large image mode
}
],
list: [
{
id: 2259,
s1: '1',
s2: '1',
price: 100,
stock_num: 110
}
],
price: '1.00',
stock_num: 227,
collection_id: 2261,
none_sku: false,
messages: [
{
datetime: '0',
multiple: '0',
name: 'Message',
type: 'text',
required: '1',
placeholder: ''
}
],
hide_stock: false,
properties: [
{
k_id: 123,
k: 'More',
is_multiple: true,
v: [
{
id: 1222,
name: 'Tea',
price: 1,
},
{
id: 1223,
name: 'Water',
price: 1,
}
],
}
]
}
```
### properties Data Structure
```js
[
{
k_id: 123,
k: 'More',
is_multiple: true,
v: [
{
id: 1222,
name: 'Tea',
price: 1,
},
{
id: 1223,
name: 'Water',
price: 1,
},
],
},
];
```
### initialSku Data Structure
```js
{
// Key:skuKeyStr
// Value:skuValueId
s1: '30349',
s2: '1193',
selectedNum: 3,
selectedProp: {
123: [1222]
}
}
```
### Goods Data Structure
```js
goods: {
picture: 'https://img.yzcdn.cn/1.jpg';
}
```
### customStepperConfig Data Structure
```js
customStepperConfig: {
// custom quota text
没有合适的资源?快使用搜索试试~ 我知道了~
Vant移动端组件库 v2.12.0
共1046个文件
js:291个
md:180个
ts:147个
10 下载量 8 浏览量
2020-12-28
13:19:42
上传
评论
收藏 22.05MB ZIP 举报
温馨提示
为您提供Vant移动端组件库下载,Vant 是一套轻量、可靠的移动端组件库。通过 Vant,可以快速搭建出风格统一的页面,提升开发效率。特性:1、60+ 高质量组件2、95% 单元测试覆盖率3、完善的中英文文档和示例4、支持按需引入5、支持主题定制6、支持国际化7、支持 TS8、支持 SSR建议搭配 webpack,babel 使用 Vant,这样可以使用 webpack 提供的丰富插件和个性化配置。Vant 支持了 babel-
资源详情
资源评论
资源推荐
收起资源包目录
Vant移动端组件库 v2.12.0 (1046个子文件)
.editorconfig 214B
.eslintignore 25B
.gitignore 150B
.gitignore 44B
changelog-commit.hbs 325B
changelog-main.hbs 149B
changelog-header.hbs 92B
下载说明.htm 3KB
index.html 1KB
index.html 1KB
area.js 103KB
vant.config.js 20KB
Sku.js 20KB
index.js 14KB
index.spec.js 12KB
index.js 12KB
index.spec.js 10KB
index.js 10KB
index.js 10KB
props.spec.js 10KB
index.spec.js 10KB
index.js 10KB
index.js 9KB
index.spec.js 9KB
index.js 9KB
index.spec.js 9KB
index.spec.js 8KB
index.spec.js 8KB
PickerColumn.js 8KB
index.spec.js 8KB
index.js 8KB
Month.js 7KB
index.js 7KB
index.js 7KB
index.spec.js 7KB
date-picker.spec.js 6KB
index.spec.js 6KB
ImagePreviewItem.js 6KB
index.spec.js 6KB
DatePicker.js 6KB
index.js 6KB
Dialog.js 6KB
index.js 5KB
prop.spec.js 5KB
index.js 5KB
index.js 5KB
index.spec.js 5KB
index.js 5KB
index.spec.js 5KB
SkuMessages.js 5KB
field-type.spec.js 5KB
index.js 5KB
codepoints.js 5KB
index.spec.js 5KB
index.js 5KB
ImagePreview.js 5KB
index.spec.js 5KB
index.js 5KB
index.spec.js 5KB
index.spec.js 5KB
SkuStepper.js 4KB
index.spec.js 4KB
index.js 4KB
index.spec.js 4KB
index.js 4KB
index.js 4KB
index.spec.js 4KB
cascade.spec.js 4KB
index.spec.js 4KB
index.js 4KB
index.spec.js 4KB
index.spec.js 4KB
config.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
sku-helper.js 4KB
index.js 4KB
index.js 4KB
index.spec.js 4KB
index.js 4KB
index.spec.js 4KB
index.js 4KB
index.spec.js 4KB
index.js 4KB
index.spec.js 4KB
directive.js 3KB
time-picker.spec.js 3KB
index.spec.js 3KB
index.spec.js 3KB
index.js 3KB
methods.spec.js 3KB
index.js 3KB
index.js 3KB
index.spec.js 3KB
index.spec.js 3KB
checkbox.js 3KB
index.spec.js 3KB
index.spec.js 3KB
mobile.js 3KB
共 1046 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
weixin_38733414
- 粉丝: 11
- 资源: 987
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【新增】-110 -食堂薪酬体系设计方案.doc
- 【新增】-112 -私立学校薪酬福利方案.doc
- 【新增】-113 -通用薪酬绩效管理制度方案.doc
- 【新增】-117 -外贸业务薪资及提成方案(暂行).doc
- 【新增】-118 -万科房地产公司全套销售薪酬管理制度 (1).doc
- 【新增】-116 -外贸薪酬制度原版.doc
- 【新增】-124 -物业公司薪酬体系方案(1).doc
- 【新增】-121 -物业公司绩效考核及薪酬方案.doc
- 【新增】-125 -物业公司组织架构与薪酬设计(修订版).doc
- 【新增】-129 -新华医院薪酬方案设计报告.doc
- 【新增】-134 -信托投资公司薪酬设计方案.doc
- 【新增】-137 -学校食堂员工薪资方案.doc
- 【新增】-139 -药店薪酬体系设计方案.doc
- 【新增】-138 -学校薪酬体系设计方案.doc
- 基于matlab 的ofdm仿真 具体点 想要加好友 不同调制方式ofdm误码率分析
- 【新增】-142 -油田公司薪酬制度与薪酬体系设计方案.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0