Merge branch 'dev'

This commit is contained in:
niunai 2018-03-09 12:04:26 +08:00
commit 495e1ac65b
165 changed files with 1471 additions and 20308 deletions

View File

@ -46,7 +46,6 @@ module.exports = {
'eol-last': 2,
'eqeqeq': [2, 'allow-null'],
'generator-star-spacing': [2, { 'before': true, 'after': true }],
'handle-callback-err': [2, '^(err|error)$' ],
'indent': [2, 2, { 'SwitchCase': 1 }],
'jsx-quotes': [2, 'prefer-double'],
'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],

View File

@ -62,7 +62,7 @@ vant
- 添加测试代码
需要在 `test/unit/specs` 目录下增加对应组件的测试文件,以 .spec.js 结尾,如:`button.spec.js`。测试框架使用了 karma + mocha + sinon + chaivue 相关的操作使用了 [avoriaz](https://github.com/eddyerburgh/avoriaz)
需要在 `test/specs` 目录下增加对应组件的测试文件,以 .spec.js 结尾,如:`button.spec.js`。测试框架使用了 karma + mocha + sinon + chaivue 相关的操作使用了 [avoriaz](https://github.com/eddyerburgh/avoriaz)
## 组件文档如何编写

6
.gitignore vendored
View File

@ -5,13 +5,9 @@
.vscode
packages/**/lib
lib/
lib/*
!lib/index.js
!lib/style.css
node_modules
example/dist
/docs/dist
test/unit/coverage
test/coverage
packages/vant-css/build
packages/vant-css/icons
docs/examples-dist

View File

@ -16,4 +16,4 @@ script:
npm run lint && npm run test
after_success:
- |
cat ./test/unit/coverage/lcov.info | ./node_modules/.bin/codecov
cat ./test/coverage/lcov.info | ./node_modules/.bin/codecov

View File

@ -62,7 +62,7 @@ import { Button } from 'vant';
#### 2. Manually import
```js
import { Button } from 'vant/lib/button';
import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```

View File

@ -59,7 +59,7 @@ import { Button } from 'vant';
#### 方式二. 按需引入组件
```js
import { Button } from 'vant/lib/button';
import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```

View File

@ -33,13 +33,11 @@ function compile(dir) {
// 移除 vant-css
if (file.indexOf('vant-css') !== -1) {
fs.removeSync(absolutePath);
}
// 遍历文件夹
else if (isDir(absolutePath)) {
// 遍历文件夹
} else if (isDir(absolutePath)) {
return compile(absolutePath);
}
// 编译 .vue 文件
else if (/\.vue$/.test(file)) {
// 编译 .vue 文件
} else if (/\.vue$/.test(file)) {
const source = fs.readFileSync(absolutePath, 'utf-8');
fs.removeSync(absolutePath);
@ -49,9 +47,13 @@ function compile(dir) {
fs.outputFileSync(output, compiler(source, compilerOption).js);
} else if (/\.js$/.test(file)) {
babel.transformFile(absolutePath, compilerOption.babel, (err, { code }) => {
fs.outputFileSync(absolutePath, code);
});
babel.transformFile(
absolutePath,
compilerOption.babel,
(err, { code }) => {
fs.outputFileSync(absolutePath, code);
}
);
}
});
}

View File

@ -13,8 +13,8 @@ const chalk = require('chalk');
require('shelljs/global');
// 1. lint
log('Starting', 'lint');
exec('npm run lint --silent');
log('Starting', 'lint');
exec('npm run lint --silent');
log('Finished', 'lint');
// 2. build entry
@ -32,7 +32,7 @@ log('Starting', 'build:vant-css');
exec('npm run build:vant-css --silent');
log('Finished', 'build:vant-css');
// 5. build vant.js
// 5. build vant.js
log('Starting', 'build:vant');
exec('npm run build:vant --silent');
log('Finished', 'build:vant');
@ -46,7 +46,7 @@ log('Finished', 'build:style-entries');
function log(status, action, breakLine) {
const now = new Date();
const clock = `${breakLine ? '\n' : ''}[${padZero(now.getHours())}:${padZero(now.getMinutes())}:${padZero(now.getSeconds())}]`;
console.log(`${chalk.gray(clock)} ${status} '${action ? chalk.cyan.bold(action ) : ''}'`);
console.log(`${chalk.gray(clock)} ${status} '${action ? chalk.cyan.bold(action) : ''}'`);
}
function padZero(num) {

View File

@ -6,7 +6,6 @@ const fs = require('fs-extra');
const path = require('path');
const components = require('./get-components')();
const dependencyTree = require('dependency-tree');
const SEP = path.sep;
components.forEach(componentName => {

View File

@ -4,5 +4,5 @@ const path = require('path');
module.exports = function() {
const dirs = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const excludes = ['index.js', 'vant-css', 'mixins', 'utils', '.DS_Store'];
return dirs.filter(dirName => excludes.indexOf(dirName) === -1)
}
return dirs.filter(dirName => excludes.indexOf(dirName) === -1);
};

View File

@ -1,50 +1,29 @@
const webpack = require('webpack');
const config = require('./webpack.config.dev.js');
const isMinify = process.argv.indexOf('-p') !== -1;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isMinify = process.argv.indexOf('-p') !== -1;
config.entry = {
'vant': './packages/index.js'
};
config.output = {
filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
library: 'vant',
libraryTarget: 'umd',
umdNamedDefine: true
};
config.externals = {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
};
config.plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
vue: {
autoprefixer: false,
preserveWhitespace: false
}
module.exports = Object.assign({}, config, {
entry: {
'vant': './packages/index.js'
},
output: {
filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
library: 'vant',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
}),
new webpack.optimize.ModuleConcatenationPlugin()
];
// analyze bundle size if need
// if (isMinify) {
// config.plugins.push(new BundleAnalyzerPlugin());
// }
delete config.devtool;
module.exports = config;
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.ModuleConcatenationPlugin()
]
});

View File

@ -14,9 +14,8 @@ const cache = {
module.exports = {
entry: {
vendor: ['packages'],
'vant-docs': './docs/src/index.js',
'vant-examples': './docs/src/examples.js'
'vant-mobile': './docs/src/mobile.js'
},
output: {
path: path.join(__dirname, '../docs/dist'),
@ -90,7 +89,6 @@ module.exports = {
}
]
},
devtool: 'source-map',
plugins: [
new ProgressBarPlugin(),
new HtmlWebpackPlugin({
@ -100,7 +98,7 @@ module.exports = {
inject: true
}),
new HtmlWebpackPlugin({
chunks: ['vendor', 'vant-examples'],
chunks: ['vendor', 'vant-mobile'],
template: 'docs/src/index.tpl',
filename: 'examples.html',
inject: true

View File

@ -6,27 +6,17 @@ const devConfig = require('./webpack.config.dev.js');
module.exports = merge(devConfig, {
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: 'https://b.yzcdn.cn/zanui/vant/',
publicPath: 'https://img.yzcdn.cn/zanui/vant/',
filename: '[name].[hash:8].js',
umdNamedDefine: true,
chunkFilename: 'async_[name].[chunkhash:8].js'
},
devtool: false,
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true
},
output: {
comments: false
},
sourceMap: false
})
new webpack.optimize.UglifyJsPlugin()
]
});

View File

@ -26,6 +26,7 @@ export default {
'address-list': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/address-list'), 'address-list')), 'address-list')),
'area': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/area'), 'area')), 'area')),
'badge': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/badge'), 'badge')), 'badge')),
'built-in-style': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/built-in-style'), 'built-in-style')), 'built-in-style')),
'button': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/button'), 'button')), 'button')),
'card': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/card'), 'card')), 'card')),
'cell-swipe': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/cell-swipe'), 'cell-swipe')), 'cell-swipe')),

View File

@ -0,0 +1,85 @@
<template>
<demo-section>
<demo-block :title="$t('ellipsis')">
<div class="van-ellipsis">{{ $t('text') }}</div>
</demo-block>
<demo-block :title="$t('hairline')">
<div class="van-hairline--top" />
</demo-block>
<demo-block :title="$t('animation')">
<van-switch-cell v-model="show" :title="$t('toggle')" :border="false" />
<van-row>
<transition name="van-fade">
<van-col span="8" v-show="show">Fade</van-col>
</transition>
<transition name="van-slide-bottom">
<van-col span="8" v-show="show">Slide Bottom</van-col>
</transition>
</van-row>
</demo-block>
</demo-section>
</template>
<script>
export default {
i18n: {
'zh-CN': {
hairline: '1px 边框',
ellipsis: '文字省略',
animation: '动画',
toggle: '切换动画',
text: '这是一段宽度限制 250px 的文字,后面的内容会省略'
},
'en-US': {
hairline: 'Hairline',
ellipsis: 'Text Ellipsis',
animation: 'Animation',
toggle: 'Switch animation',
text: 'This is a paragraph of 250px width limit, the back will be omitted.'
}
},
data() {
return {
show: true
};
}
};
</script>
<style lang="postcss">
.demo-built-in-style {
.van-ellipsis {
font-size: 13px;
margin-left: 15px;
max-width: 250px;
}
.van-hairline--top {
height: 30px;
background-color: #fff;
&::after {
top: 15px;
}
}
.van-col {
height: 50px;
color: #fff;
font-size: 14px;
border-radius: 3px;
text-align: center;
line-height: 50px;
margin-left: 15px;
background-color: #39a9ed;
}
.van-switch-cell {
margin-bottom: 15px;
}
}
</style>

View File

@ -9,6 +9,11 @@
<van-checkbox :value="true" disabled>{{ $t('checkbox') }} 2</van-checkbox>
</demo-block>
<demo-block :title="$t('labelDisabled')">
<van-checkbox v-model="checkbox3" label-disabled>{{ $t('checkbox') }} 2</van-checkbox>
<van-checkbox v-model="checkbox4" label-disabled>{{ $t('checkbox') }} 2</van-checkbox>
</demo-block>
<demo-block :title="$t('title3')">
<van-checkbox-group v-model="result">
<van-checkbox
@ -30,6 +35,16 @@
</van-cell-group>
</van-checkbox-group>
</demo-block>
<demo-block :title="$t('title5')">
<van-checkbox-group v-model="result2" :max="max">
<van-cell-group>
<van-cell v-for="(item, index) in list" :key="index">
<van-checkbox :name="item">{{ $t('checkbox') }} {{ item }}</van-checkbox>
</van-cell>
</van-cell-group>
</van-checkbox-group>
</demo-block>
</demo-section>
</template>
@ -38,13 +53,17 @@ export default {
i18n: {
'zh-CN': {
checkbox: '复选框',
labelDisabled: '禁用 Checkbox 内容部分点击事件',
title3: 'Checkbox 组',
title4: '与 Cell 组件一起使用'
title4: '与 Cell 组件一起使用',
title5: '设置最大可选数',
},
'en-US': {
checkbox: 'Checkbox',
labelDisabled: 'Disable Checkbox Label click event',
title3: 'Checkbox Group',
title4: 'Inside a Cell'
title4: 'Inside a Cell',
title5: 'Maximum amount of checked options'
}
},
@ -52,12 +71,16 @@ export default {
return {
checkbox1: true,
checkbox2: true,
checkbox3: false,
checkbox4: true,
list: [
'a',
'b',
'c'
],
result: ['a', 'b']
result: ['a', 'b'],
result2: [],
max: 2
};
}
};
@ -72,15 +95,13 @@ export default {
.van-cell {
.van-checkbox {
margin: 0;
}
display: flex;
flex-direction: row-reverse;
.van-checkbox__input {
float: right;
position: static;
}
span {
margin: 0;
&__label {
margin: 0;
flex: 1;
}
}
}
}

View File

@ -115,7 +115,7 @@ export default {
});
},
randomId(max = 999999) {
return Math.floor(Math.random() * max) + 1
return Math.floor(Math.random() * max) + 1;
}
}
};

View File

@ -2,13 +2,13 @@
<demo-section>
<demo-block :title="$t('basicUsage')">
<van-button @click="show1 = true">{{ $t('button1') }}</van-button>
<van-popup v-model="show1" :prevent-scroll="true">{{ $t('content') }}</van-popup>
<van-popup v-model="show1" prevent-scroll>{{ $t('content') }}</van-popup>
</demo-block>
<demo-block :title="$t('position')">
<van-button @click="show2 = true;">{{ $t('button2') }}</van-button>
<van-popup v-model="show2" position="bottom" :prevent-scroll="true">
<van-popup v-model="show2" position="bottom" prevent-scroll>
<van-tabs>
<van-tab class="custom-pane" title="Tab1">
<ul class="scroller">

View File

@ -10,9 +10,10 @@
:hide-stock="$t('sku').sku.hide_stock"
:quota="$t('sku').quota"
:quota-used="$t('sku').quota_used"
:reset-stepper-on-hide="true"
:reset-selected-sku-on-hide="true"
:disable-stepper-input="true"
reset-stepper-on-hide
reset-selected-sku-on-hide
disable-stepper-input
:close-on-click-overlay="closeOnClickOverlay"
:message-config="messageConfig"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@ -48,10 +49,10 @@
:goods="$t('sku').goods_info"
:goods-id="$t('sku').goods_id"
:hide-stock="$t('sku').sku.hide_stock"
:show-add-cart-btn="true"
:quota="$t('sku').quota"
:quota-used="$t('sku').quota_used"
:reset-stepper-on-hide="true"
show-add-cart-btn
reset-stepper-on-hide
:initial-sku="initialSku"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@ -96,6 +97,7 @@ export default {
showBase: false,
showCustom: false,
showStepper: false,
closeOnClickOverlay: true,
initialSku: {
s1: '30349',
s2: '1193'

View File

@ -16,6 +16,15 @@
</van-swipe-item>
</van-swipe>
</demo-block>
<demo-block :title="$t('title3')">
<van-swipe @change="onChange">
<van-swipe-item>1</van-swipe-item>
<van-swipe-item>2</van-swipe-item>
<van-swipe-item>3</van-swipe-item>
<van-swipe-item>4</van-swipe-item>
</van-swipe>
</demo-block>
</demo-section>
</template>
@ -23,10 +32,14 @@
export default {
i18n: {
'zh-CN': {
title2: '图片懒加载'
title2: '图片懒加载',
title3: '监听 change 事件',
message: '当前 Swipe 索引:'
},
'en-US': {
title2: 'Image Lazyload'
title2: 'Image Lazyload',
title3: 'Change Event',
message: 'Current Swipe index:'
}
},
@ -39,6 +52,12 @@ export default {
'https://img.yzcdn.cn/public_files/2017/09/05/fd08f07665ed67d50e11b32a21ce0682.jpg'
]
};
},
methods: {
onChange(index) {
this.$toast(this.$t('message') + index);
}
}
};
</script>

View File

@ -106,7 +106,7 @@ export default {
<style lang="postcss">
.demo-tab {
margin-bottom: 700px;
margin-bottom: 500px;
.van-tab .van-icon {
margin-right: 5px;

View File

@ -68,6 +68,7 @@ export default {
| show-search-result | Whether to show address search result | `Boolean` | `false` | - |
| is-saving | Whether to show save button loading status | `Boolean` | `false` | - |
| is-deleting | Whether to show delete button loading status | `Boolean` | `false` | - |
| tel-validator | The method to validate tel | `(tel: string) => boolean` | - | - |
### Event

View File

@ -0,0 +1,48 @@
## Built-in Style
Vant contains some common styles that can be used directly by the className.
### Text ellipsis
When the text content length exceeds the maximum container width, the excess text is automatically omitted.
```html
<div class="van-ellipsis">
This is a paragraph of 250px width limit, the back will be omitted.
</div>
```
### Hairline
Add 1px border under the Retina screen for the element, based on a pseudo element.
```html
<!-- border top -->
<div class="van-hairline--top"></div>
<!-- border bottom -->
<div class="van-hairline--bottom"></div>
<!-- border left -->
<div class="van-hairline--left"></div>
<!-- border right -->
<div class="van-hairline--right"></div>
<!-- border top & bottom -->
<div class="van-hairline--top-bottom"></div>
<!-- full border -->
<div class="van-hairline--surround"></div>
```
### Animation
```html
<!-- fade in -->
<transition name="van-fade">
<div v-show="visible">Fade</div>
</transition>
<!-- slide bottom -->
<transition name="van-slide-bottom">
<div v-show="visible">Fade</div>
</transition>
```

View File

@ -1,5 +1,64 @@
## Changelog
### [0.12.12](https://github.com/youzan/vant/tree/v0.12.12)
`2018-03-06`
**Improvements**
* Swipe: support disable loop [\#670](https://github.com/youzan/vant/pull/670) [@chenjiahan](https://github.com/chenjiahan)
* Document: add swipe change event demo [\#666](https://github.com/youzan/vant/pull/666) [@chenjiahan](https://github.com/chenjiahan)
* update static source CDN domain [\#652](https://github.com/youzan/vant/pull/652) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* fix Field disabled color in safari [\#669](https://github.com/youzan/vant/pull/669) [@chenjiahan](https://github.com/chenjiahan)
* fix Swipe autoplay not stop when value set to 0 [\#660](https://github.com/youzan/vant/pull/660) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.11](https://github.com/youzan/vant/tree/v0.12.11)
`2018-02-27`
**Improvements**
* Checkbox: add label-disabled prop [\#644](https://github.com/youzan/vant/pull/644) [@ddchef](https://github.com/ddchef)
* Popup: add click-overlay event [\#647](https://github.com/youzan/vant/pull/647) [@chenjiahan](https://github.com/chenjiahan)
* Icon: add warn icon [\#651](https://github.com/youzan/vant/pull/651) [@chenjiahan](https://github.com/chenjiahan)
* Icon: add info-o icon, optimize checked & underway icon [\#648](https://github.com/youzan/vant/pull/648) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* fix Button loading horizontal align [\#645](https://github.com/youzan/vant/pull/645) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.10](https://github.com/youzan/vant/tree/v0.12.10)
`2018-02-12`
**Improvements**
* add build-in style document [\#633](https://github.com/youzan/vant/pull/633) [@chenjiahan](https://github.com/chenjiahan)
* Checkbox: optimzie DOM struct [\#636](https://github.com/youzan/vant/pull/636) [@chenjiahan](https://github.com/chenjiahan)
* Checkbox: support config the maximum amount of checked options [\#631](https://github.com/youzan/vant/pull/631) [@mpandar](https://github.com/mpandar)
**Bug Fixes**
* Stepper: change event error when clear input [\#635](https://github.com/youzan/vant/pull/635) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.9](https://github.com/youzan/vant/tree/v0.12.9)
`2018-02-08`
**Improvements**
* PullRefresh: add refersh event [\#625](https://github.com/youzan/vant/pull/625) [@chenjiahan](https://github.com/chenjiahan)
* Circle: optimzie linecap [\#624](https://github.com/youzan/vant/pull/624) [@chenjiahan](https://github.com/chenjiahan)
* Picker: add loading prop [\#619](https://github.com/youzan/vant/pull/619) [@chenjiahan](https://github.com/chenjiahan)
* Loading: add size prop [\#620](https://github.com/youzan/vant/pull/620) [@chenjiahan](https://github.com/chenjiahan)
* Loading: add circular type [\#618](https://github.com/youzan/vant/pull/618) [@chenjiahan](https://github.com/chenjiahan)
* Loading: change default type to circular [\#623](https://github.com/youzan/vant/pull/623) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* fix Sku message observation [\#627](https://github.com/youzan/vant/pull/627) [@w91](https://github.com/w91)
### [0.12.8](https://github.com/youzan/vant/tree/v0.12.8)
`2018-02-07`

View File

@ -38,7 +38,7 @@ When Checkboxes are inside a CheckboxGroup, the checked checkboxes's name is an
<van-checkbox-group v-model="result">
<van-checkbox
v-for="(item, index) in list"
:key="index"
:key="item"
:name="item"
>
Checkbox {{ item }}
@ -57,24 +57,40 @@ export default {
};
```
#### Maximum amount of checked options
```html
<van-checkbox-group v-model="result" :max="2">
<van-checkbox
v-for="(item, index) in list"
:name="item"
:key="item"
>
Checkbox {{ item }}
</van-checkbox>
</van-checkbox-group>
```
#### Inside a Cell
```html
<van-checkbox-group v-model="result">
<van-cell-group>
<van-cell v-for="(item, index) in list" :key="index">
<van-cell v-for="(item, index) in list" :key="item">
<van-checkbox :name="item">Checkbox {{ item }}</van-checkbox>
</van-cell>
</van-cell-group>
</van-checkbox-group>
```
### Checkbox API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| name | Checkbox name | `Boolean` | `false` | - |
| disabled | Diable checkbox | `Boolean` | `false` | - |
| label-disabled | Whether to disable label click | `Boolean` | `false` | - |
| shape | Checkbox shape | `String` | `round` | `square` |
### CheckboxGroup API
@ -82,6 +98,7 @@ export default {
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| disabled | Disable all checkboxes | `Boolean` | `false` | - |
| max | Maximum amount of checked options | `Number` | `0`(Unlimited) | - |
### Checkbox Event

View File

@ -161,6 +161,7 @@ export default {
| is-edit | Whether is editing | `Boolean` | `false` | - |
| is-saving | Whether to show save button loading status | `Boolean` | `false` | - |
| is-deleting | Whether to show delete button loading status | `Boolean` | `false` | - |
| tel-validator | The method to validate tel | `(tel: string) => boolean` | - | - |
### ContactEdit Event

View File

@ -107,8 +107,8 @@ export default {
| discount | Discount | `Number` |
| denominations | Denominations | `Number` |
| origin_condition | Condition | `Number` |
| start_at | Start time | `Number` |
| end_at | End time | `Number` |
| start_at | Start time (Timestmap, unit second) | `Number` |
| end_at | End time (Timestmap, unit second) | `Number` |
| reason | Unavailable reason | `String` |
| value | Value | `Number` |

View File

@ -49,3 +49,9 @@ Use `position` prop to set popup display position
| transition | Transition | `String` | `popup-slide` | - |
| prevent-scroll | Prevent background scroll | `Boolean` | `false` | - |
| get-container | Return the mount node for Popup | `Function` | - | `() => HTMLElement` |
### Event
| Event | Description | Arguments |
|-----------|-----------|-----------|
| click-overlay | Triggered when click overlay | - |

View File

@ -34,7 +34,7 @@ import { Button } from 'vant';
#### 2. Manually import
```js
import { Button } from 'vant/lib/button';
import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```

View File

@ -21,6 +21,7 @@ Vue.use(Sku);
:quota-used="quotaUsed"
:reset-stepper-on-hide="resetStepperOnHide"
:reset-selected-sku-on-hide="resetSelectedSkuOnHide"
:close-on-click-overlay="closeOnClickOverlay"
:disable-stepper-input="disableStepperInput"
:message-config="messageConfig"
@buy-clicked="onBuyClicked"
@ -55,10 +56,10 @@ Vue.use(Sku);
:goods="goods"
:goods-id="goodsId"
:hide-stock="sku.hide_stock"
:show-add-cart-btn="true"
:quota="quota"
:quota-used="quotaUsed"
:reset-stepper-on-hide="true"
show-add-cart-btn
reset-stepper-on-hide
:initial-sku="initialSku"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@ -89,6 +90,7 @@ Vue.use(Sku);
| 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 click overlay | `Boolean` | `false` | - |
| stepper-title | Quantity title | `String` | `Quantity` | - |
| custom-stepper-config | Custom stepper related config | `Object` | `{}` | - |
| message-config | Message related config | `Object` | `{}` | - |

View File

@ -45,12 +45,34 @@ export default {
}
```
#### change event
```html
<van-swipe @change="onChange">
<van-swipe-item>1</van-swipe-item>
<van-swipe-item>2</van-swipe-item>
<van-swipe-item>3</van-swipe-item>
<van-swipe-item>4</van-swipe-item>
</van-swipe>
```
```js
export default {
methods: {
onChange(index) {
Toast('Current Swipe index:' + index);
}
}
}
```
### API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| autoplay | Autoplay interval (ms) | `Number` | - | - |
| duration | Animation duration (ms) | `Number` | `500` | - |
| loop | Whether to enable loop | `Boolean` | `true` | - |
| show-indicators | Whether to show indocators | `Boolean` | `true` | - |
| initial-swipe | Index of initial swipe, start from 0 | `Number` | `0` | - |

View File

@ -18,6 +18,7 @@ export default {
'zh-CN/address-list': wrapper(r => require.ensure([], () => r(require('./zh-CN/address-list.md')), 'zh-CN/address-list')),
'zh-CN/area': wrapper(r => require.ensure([], () => r(require('./zh-CN/area.md')), 'zh-CN/area')),
'zh-CN/badge': wrapper(r => require.ensure([], () => r(require('./zh-CN/badge.md')), 'zh-CN/badge')),
'zh-CN/built-in-style': wrapper(r => require.ensure([], () => r(require('./zh-CN/built-in-style.md')), 'zh-CN/built-in-style')),
'zh-CN/button': wrapper(r => require.ensure([], () => r(require('./zh-CN/button.md')), 'zh-CN/button')),
'zh-CN/card': wrapper(r => require.ensure([], () => r(require('./zh-CN/card.md')), 'zh-CN/card')),
'zh-CN/cell-swipe': wrapper(r => require.ensure([], () => r(require('./zh-CN/cell-swipe.md')), 'zh-CN/cell-swipe')),
@ -72,6 +73,7 @@ export default {
'en-US/address-list': wrapper(r => require.ensure([], () => r(require('./en-US/address-list.md')), 'en-US/address-list')),
'en-US/area': wrapper(r => require.ensure([], () => r(require('./en-US/area.md')), 'en-US/area')),
'en-US/badge': wrapper(r => require.ensure([], () => r(require('./en-US/badge.md')), 'en-US/badge')),
'en-US/built-in-style': wrapper(r => require.ensure([], () => r(require('./en-US/built-in-style.md')), 'en-US/built-in-style')),
'en-US/button': wrapper(r => require.ensure([], () => r(require('./en-US/button.md')), 'en-US/button')),
'en-US/card': wrapper(r => require.ensure([], () => r(require('./en-US/card.md')), 'en-US/card')),
'en-US/cell-swipe': wrapper(r => require.ensure([], () => r(require('./en-US/cell-swipe.md')), 'en-US/cell-swipe')),

View File

@ -67,6 +67,7 @@ export default {
| show-search-result | 是否显示搜索结果 | `Boolean` | `false` | - |
| is-saving | 是否显示保存按钮加载动画 | `Boolean` | `false` | - |
| is-deleting | 是否显示删除按钮加载动画 | `Boolean` | `false` | - |
| tel-validator | 手机号格式校验函数 | `(tel: string) => boolean` | - | - |
### Event

View File

@ -0,0 +1,47 @@
## 内置样式
Vant 中默认包含了一些常用样式,可以直接通过 className 的方式使用。
### 文字省略
当文本内容长度超过容器最大宽度时,自动省略多余的文本。
```html
<div class="van-ellipsis">这是一段宽度限制 250px 的文字,后面的内容会省略</div>
```
### 1px 边框
为元素添加 Retina 屏幕下的 1px 边框(即 hairline基于伪类 transform 实现。
```html
<!-- 上边框 -->
<div class="van-hairline--top"></div>
<!-- 下边框 -->
<div class="van-hairline--bottom"></div>
<!-- 左边框 -->
<div class="van-hairline--left"></div>
<!-- 右边框 -->
<div class="van-hairline--right"></div>
<!-- 上下边框 -->
<div class="van-hairline--top-bottom"></div>
<!-- 全边框 -->
<div class="van-hairline--surround"></div>
```
### 动画
可以通过 `transition` 组件使用内置的动画
```html
<!-- 淡入 -->
<transition name="van-fade">
<div v-show="visible">Fade</div>
</transition>
<!-- 下滑 -->
<transition name="van-slide-bottom">
<div v-show="visible">Fade</div>
</transition>
```

View File

@ -1,5 +1,95 @@
## 更新日志
## [v0.12.12](https://github.com/youzan/vant/tree/v0.12.12) (2018-03-06)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.11...v0.12.12)
**Issue**
- Tabs 组件的sticky设置 [\#662](https://github.com/youzan/vant/issues/662)
- Sku组件有问题 [\#659](https://github.com/youzan/vant/issues/659)
- checkbox/radio选项不支持溢出文本 [\#658](https://github.com/youzan/vant/issues/658)
- Search组件输入内容在 iphone 内显示不完整 [\#657](https://github.com/youzan/vant/issues/657)
- van-button组件在loading时loading图标不居中 [\#655](https://github.com/youzan/vant/issues/655)
- 建议增加Scroller组件能够无限加载下拉刷新 [\#654](https://github.com/youzan/vant/issues/654)
- Icon 浏览器兼容 [\#653](https://github.com/youzan/vant/issues/653)
- Popup以及Picker同时使用时存在的一个问题是否能考虑在Popup点击遮罩层关闭时提供相应的事件 [\#646](https://github.com/youzan/vant/issues/646)
- 新增加的功能 [\#643](https://github.com/youzan/vant/issues/643)
**Improvements**
- \[new feature\] Swipe: support disable loop [\#670](https://github.com/youzan/vant/pull/670) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Field: disabled color in safari [\#669](https://github.com/youzan/vant/pull/669) ([chenjiahan](https://github.com/chenjiahan))
- \[Doc\] swipe: add change event demo [\#666](https://github.com/youzan/vant/pull/666) ([chenjiahan](https://github.com/chenjiahan))
- \[Doc\] fix Tab demo & update dependencies [\#665](https://github.com/youzan/vant/pull/665) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] optimize utils [\#661](https://github.com/youzan/vant/pull/661) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Swipe: autoplay not stop when value set to 0 [\#660](https://github.com/youzan/vant/pull/660) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] update CDN domain [\#652](https://github.com/youzan/vant/pull/652) ([chenjiahan](https://github.com/chenjiahan))
## [v0.12.11](https://github.com/youzan/vant/tree/v0.12.11) (2018-02-27)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.10...v0.12.11)
**Issue**
- picker如何设置初始选中默认值 [\#649](https://github.com/youzan/vant/issues/649)
- 官方可以在release里面提供编译后的js文件吗可以直接用在html里面那种 [\#642](https://github.com/youzan/vant/issues/642)
- Vue.prototype.$toast = Toast [\#641](https://github.com/youzan/vant/issues/641)
- ImagePreview鼠标单击图片外的黑色背景部分无法关闭 [\#637](https://github.com/youzan/vant/issues/637)
- van-stepper 的异常 [\#634](https://github.com/youzan/vant/issues/634)
- 期待checkbox支持最大选择数量功能 [\#617](https://github.com/youzan/vant/issues/617)
**Improvements**
- \[Improvement\] Icon: add warn icon [\#651](https://github.com/youzan/vant/pull/651) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] add checkbox labelDisabled test case [\#650](https://github.com/youzan/vant/pull/650) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Icon: add info-o icon [\#648](https://github.com/youzan/vant/pull/648) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Popup: add click-overlay event [\#647](https://github.com/youzan/vant/pull/647) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Button loading horizontal align [\#645](https://github.com/youzan/vant/pull/645) ([chenjiahan](https://github.com/chenjiahan))
- \[new feature\]Checkbox: support disabled label [\#644](https://github.com/youzan/vant/pull/644) ([ddchef](https://github.com/ddchef))
## [v0.12.10](https://github.com/youzan/vant/tree/v0.12.10) (2018-02-12)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.9...v0.12.10)
**Issue**
- 这个参数到底是毫秒还是秒,还是分钟呀?! [\#632](https://github.com/youzan/vant/issues/632)
- 建议Toast.loading 增加一个 loading关闭api [\#629](https://github.com/youzan/vant/issues/629)
- 修改地址时,怎么设置默认值 [\#628](https://github.com/youzan/vant/issues/628)
- pull-refresh [\#622](https://github.com/youzan/vant/issues/622)
- Actionsheet 没有设置默认选中的啊 [\#621](https://github.com/youzan/vant/issues/621)
**Improvements**
- \[Doc\] optimzie router & remove unused code [\#640](https://github.com/youzan/vant/pull/640) ([chenjiahan](https://github.com/chenjiahan))
- simplify test config [\#639](https://github.com/youzan/vant/pull/639) ([chenjiahan](https://github.com/chenjiahan))
- simplify build config [\#638](https://github.com/youzan/vant/pull/638) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Checkbox: remove unnecessary DOM [\#636](https://github.com/youzan/vant/pull/636) ([chenjiahan](https://github.com/chenjiahan))
- \[bugfix\] Stepper: change event error when clear input [\#635](https://github.com/youzan/vant/pull/635) ([chenjiahan](https://github.com/chenjiahan))
- \[Doc\] add build-in style document [\#633](https://github.com/youzan/vant/pull/633) ([chenjiahan](https://github.com/chenjiahan))
- \[new feature\] Checkbox: support config the maximum amount of checked options [\#631](https://github.com/youzan/vant/pull/631) ([mpandar](https://github.com/mpandar))
## [v0.12.9](https://github.com/youzan/vant/tree/v0.12.9) (2018-02-08)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.8...v0.12.9)
**Breaking changes**
- 能否增加一个进度环组件Circle [\#599](https://github.com/youzan/vant/issues/599)
**Issue**
- PullRefresh 下拉刷新?没有下拉加载。。。社区怎么没人啊? [\#614](https://github.com/youzan/vant/issues/614)
- tabs 的title能否加个slot? [\#574](https://github.com/youzan/vant/issues/574)
**Improvements**
- \[bugfix\] 修复sku数据改变后skuMessages没有更新的bug [\#627](https://github.com/youzan/vant/pull/627) ([w91](https://github.com/w91))
- \[Doc\] optimzie demo display [\#626](https://github.com/youzan/vant/pull/626) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] PullRefresh: add refersh event [\#625](https://github.com/youzan/vant/pull/625) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Circle: optimzie linecap [\#624](https://github.com/youzan/vant/pull/624) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Loading: change default type to circular [\#623](https://github.com/youzan/vant/pull/623) ([chenjiahan](https://github.com/chenjiahan))
- \[Improvement\] Loading: add size prop [\#620](https://github.com/youzan/vant/pull/620) ([chenjiahan](https://github.com/chenjiahan))
- \[new feature\] Picker: add loading prop [\#619](https://github.com/youzan/vant/pull/619) ([chenjiahan](https://github.com/chenjiahan))
- \[new feature\] Loading: add circular type [\#618](https://github.com/youzan/vant/pull/618) ([chenjiahan](https://github.com/chenjiahan))
## [v0.12.8](https://github.com/youzan/vant/tree/v0.12.8) (2018-02-07)
[Full Changelog](https://github.com/youzan/vant/compare/v0.12.7...v0.12.8)

View File

@ -1,5 +1,62 @@
## 更新日志
### [0.12.12](https://github.com/youzan/vant/tree/v0.12.12)
`2018-03-06`
**Improvements**
* Swipe: 新增 loop 属性,支持禁用循环滚动 [\#670](https://github.com/youzan/vant/pull/670) [@chenjiahan](https://github.com/chenjiahan)
* Document: 新增 change 事件示例 [\#666](https://github.com/youzan/vant/pull/666) [@chenjiahan](https://github.com/chenjiahan)
* 更新静态资源 CDN 域名 [\#652](https://github.com/youzan/vant/pull/652) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* 修复 Field 在 safari 下禁用态颜色过浅的问题 [\#669](https://github.com/youzan/vant/pull/669) [@chenjiahan](https://github.com/chenjiahan)
* 修复 Swipe autoplay 设置为 0 时不会立刻取消的问题 [\#660](https://github.com/youzan/vant/pull/660) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.11](https://github.com/youzan/vant/tree/v0.12.11)
`2018-02-27`
**Improvements**
* Checkbox: 新增 label-disabled 属性,支持禁用 label 点击 [\#644](https://github.com/youzan/vant/pull/644) [@ddchef](https://github.com/ddchef)
* Popup: 新增 click-overlay 事件 [\#647](https://github.com/youzan/vant/pull/647) [@chenjiahan](https://github.com/chenjiahan)
* Icon: 新增 warn 图标 [\#651](https://github.com/youzan/vant/pull/651) [@chenjiahan](https://github.com/chenjiahan)
* Icon: 新增 info-o 图标, 优化 checked & underway 图标 [\#648](https://github.com/youzan/vant/pull/648) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* 修复 Button loading 样式未居中的问题 [\#645](https://github.com/youzan/vant/pull/645) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.10](https://github.com/youzan/vant/tree/v0.12.10)
`2018-02-12`
**Improvements**
* 新增内置样式文档 [\#633](https://github.com/youzan/vant/pull/633) [@chenjiahan](https://github.com/chenjiahan)
* Checkbox: 优化 DOM 结构 [\#636](https://github.com/youzan/vant/pull/636) [@chenjiahan](https://github.com/chenjiahan)
* Checkbox: 支持设置最大可选数 [\#631](https://github.com/youzan/vant/pull/631) [@mpandar](https://github.com/mpandar)
**Bug Fixes**
* Stepper: 修复清空输入框时 change 事件未正确触发的问题 [\#635](https://github.com/youzan/vant/pull/635) [@chenjiahan](https://github.com/chenjiahan)
### [0.12.9](https://github.com/youzan/vant/tree/v0.12.9)
`2018-02-08`
**Improvements**
* PullRefresh: 新增 refersh 事件 [\#625](https://github.com/youzan/vant/pull/625) [@chenjiahan](https://github.com/chenjiahan)
* Circle: 优化线条圆角 [\#624](https://github.com/youzan/vant/pull/624) [@chenjiahan](https://github.com/chenjiahan)
* Picker: 新增 loading 属性 [\#619](https://github.com/youzan/vant/pull/619) [@chenjiahan](https://github.com/chenjiahan)
* Loading: 新增 size 属性 [\#620](https://github.com/youzan/vant/pull/620) [@chenjiahan](https://github.com/chenjiahan)
* Loading: 新增 circular 类型 [\#618](https://github.com/youzan/vant/pull/618) [@chenjiahan](https://github.com/chenjiahan)
* Loading: 默认类型调整为 circular [\#623](https://github.com/youzan/vant/pull/623) [@chenjiahan](https://github.com/chenjiahan)
**Bug Fixes**
* 修复 Sku message 更新时未重新渲染的问题 [\#627](https://github.com/youzan/vant/pull/627) [@w91](https://github.com/w91)
### [0.12.8](https://github.com/youzan/vant/tree/v0.12.8)
`2018-02-07`

View File

@ -31,7 +31,11 @@ export default {
```html
<van-checkbox v-model="checked" disabled>复选框 2</van-checkbox>
```
#### 禁用内容部分点击事件
```html
<van-checkbox v-model="checked" label-disabled>复选框 3</van-checkbox>
```
#### Checkbox 组
需要与`van-checkbox-group`一起使用,选中值是一个数组,通过`v-model`绑定在`van-checkbox-group`上,数组中的项即为选中的`Checkbox``name`属性设置的值
@ -40,7 +44,7 @@ export default {
<van-checkbox-group v-model="result">
<van-checkbox
v-for="(item, index) in list"
:key="index"
:key="item"
:name="item"
>
复选框 {{ item }}
@ -59,6 +63,20 @@ export default {
};
```
#### 设置最大可选数
```html
<van-checkbox-group v-model="result" :max="2">
<van-checkbox
v-for="(item, index) in list"
:key="item"
:name="item"
>
复选框 {{ item }}
</van-checkbox>
</van-checkbox-group>
```
#### 与 Cell 组件一起使用
此时你需要再引入`Cell``CellGroup`组件
@ -66,7 +84,7 @@ export default {
```html
<van-checkbox-group v-model="result">
<van-cell-group>
<van-cell v-for="(item, index) in list" :key="index">
<van-cell v-for="(item, index) in list" :key="item">
<van-checkbox :name="item">复选框 {{ item }}</van-checkbox>
</van-cell>
</van-cell-group>
@ -79,6 +97,7 @@ export default {
|-----------|-----------|-----------|-------------|-------------|
| name | 标识 Checkbox 名称 | `Boolean` | `false` | - |
| disabled | 是否禁用单选框 | `Boolean` | `false` | - |
| label-disabled | 是否禁用单选框内容点击 | `Boolean` | `false` | - |
| shape | 形状 | `String` | `round` | `square` |
### CheckboxGroup API
@ -86,6 +105,7 @@ export default {
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| disabled | 是否禁用所有单选框 | `Boolean` | `false` | - |
| max | 设置最大可选数 | `Number` | `0`(无限制) | - |
### Checkbox Event

View File

@ -162,6 +162,7 @@ export default {
| is-edit | 是否为编辑联系人 | `Boolean` | `false` | - |
| is-saving | 是否显示保存按钮加载动画 | `Boolean` | `false` | - |
| is-deleting | 是否显示删除按钮加载动画 | `Boolean` | `false` | - |
| tel-validator | 手机号格式校验函数 | `(tel: string) => boolean` | - | - |
### ContactEdit Event

View File

@ -110,8 +110,7 @@ export default {
| discount | 折扣0为满减券88=>8.8折 | `Number` |
| denominations | 面值0为折扣券单位分 | `Number` |
| origin_condition | 满减条件0为无门槛满XX元可用单位分 | `Number` |
| start_at | 卡有效开始时间 | `Number` |
| end_at | 卡失效日期 | `Number` |
| start_at | 卡有效开始时间 (时间戳, 单位秒) | `Number` |
| end_at | 卡失效日期 (时间戳, 单位秒) | `Number` |
| reason | 不可用原因 | `String` |
| value | 订单优惠金额,单位分 | `Number` |

View File

@ -49,3 +49,9 @@ export default {
| transition | transition 名称 | `String` | `popup-slide` | - |
| prevent-scroll | 是否防止滚动穿透 | `Boolean` | `false` | - |
| get-container | 指定弹出层挂载的 HTML 节点 | `Function` | - | `() => HTMLElement` |
### Event
| 事件名 | 说明 | 参数 |
|-----------|-----------|-----------|
| click-overlay | 点击蒙层时触发 | - |

View File

@ -32,7 +32,7 @@ import { Button } from 'vant';
#### 方式二. 按需引入组件
```js
import { Button } from 'vant/lib/button';
import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```

View File

@ -21,6 +21,7 @@ Vue.use(Sku);
:quota-used="quotaUsed"
:reset-stepper-on-hide="resetStepperOnHide"
:reset-selected-sku-on-hide="resetSelectedSkuOnHide"
:close-on-click-overlay="closeOnClickOverlay"
:disable-stepper-input="disableStepperInput"
:message-config="messageConfig"
@buy-clicked="onBuyClicked"
@ -55,10 +56,10 @@ Vue.use(Sku);
:goods="goods"
:goods-id="goodsId"
:hide-stock="sku.hide_stock"
:show-add-cart-btn="true"
:quota="quota"
:quota-used="quotaUsed"
:reset-stepper-on-hide="true"
show-add-cart-btn
reset-stepper-on-hide
:initial-sku="initialSku"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@ -90,6 +91,7 @@ Vue.use(Sku);
| reset-stepper-on-hide | 窗口隐藏时重置选择的商品数量 | `Boolean` | `false` | - |
| reset-selected-sku-on-hide | 窗口隐藏时重置已选择的sku | `Boolean` | `false` | - |
| disable-stepper-input | 是否禁用sku中stepper的input框 | `Boolean` | `false` | - |
| close-on-click-overlay | 点击popup的overlay后是否关闭弹窗 | `Boolean` | `false` | - |
| stepper-title | 数量选择组件左侧文案 | `String` | `购买数量` | - |
| custom-stepper-config | 步进器相关自定义配置 | `Object` | `{}` | - |
| message-config | 留言相关配置 | `Object` | `{}` | - |

View File

@ -45,12 +45,34 @@ export default {
}
```
#### 监听 change 事件
```html
<van-swipe @change="onChange">
<van-swipe-item>1</van-swipe-item>
<van-swipe-item>2</van-swipe-item>
<van-swipe-item>3</van-swipe-item>
<van-swipe-item>4</van-swipe-item>
</van-swipe>
```
```js
export default {
methods: {
onChange(index) {
Toast('当前 Swipe 索引:' + index);
}
}
}
```
### API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| autoplay | 自动轮播间隔,单位为 ms | `Number` | - | - |
| duration | 动画时长,单位为 ms | `Number` | `500` | - |
| loop | 是否开启循环播放 | `Boolean` | `true` | - |
| show-indicators | 是否显示指示器 | `Boolean` | `true` | - |
| initial-swipe | 初始位置,从 0 开始算 | `Number` | `0` | - |

View File

@ -19,7 +19,7 @@ export default {
computed: {
base() {
return `/${this.$vantLang}/component`;
return `/${this.$vantLang}`;
},
config() {

View File

@ -2,11 +2,9 @@
<div>
<van-nav-bar
v-show="title"
fixed
class="van-doc-nav-bar"
:title="title"
left-arrow
:left-text="$t('back')"
@click-left="onBack"
/>
<router-view />
@ -14,13 +12,11 @@
</template>
<script>
import { camelize } from 'packages/utils';
export default {
computed: {
title() {
const name = this.$route.name;
return name ? camelize(name.split('/').pop()) : '';
const { name } = this.$route.meta;
return name ? name.replace(/-/g, '') : '';
}
},
@ -43,11 +39,8 @@ body {
.van-doc-nav-bar {
.van-nav-bar__title {
font-size: 15px;
text-transform: capitalize;
}
}
.van-doc-demo-section {
padding-top: 46px;
}
</style>

View File

@ -11,7 +11,7 @@
<h2 class="zanui-desc">{{ description }}</h2>
<div class="mobile-navs">
<div class="mobile-nav-item" v-for="(item, index) in navList" v-if="item.showInMobile" :key="index">
<mobile-nav v-for="(group, index) in item.groups" :group="group" :base="base" :nav-key="index" :key="index" />
<mobile-nav v-for="(group, index) in item.groups" :group="group" :base="$vantLang" :nav-key="index" :key="index" />
</div>
</div>
</div>
@ -34,10 +34,6 @@ export default {
},
computed: {
base() {
return `${this.$vantLang}/component`;
},
navList() {
return this.docConfig[this.$vantLang].nav || [];
},
@ -64,8 +60,6 @@ export default {
width: 100%;
box-sizing: border-box;
padding: 60px 15px 20px;
position: relative;
z-index: 1;
.zanui-title,
.zanui-desc {

View File

@ -37,6 +37,10 @@ module.exports = {
title: '更新日志',
noExample: true
},
{
path: '/built-in-style',
title: '内置样式'
},
{
path: '/theme',
title: '定制主题',
@ -124,10 +128,6 @@ module.exports = {
path: '/progress',
title: 'Progress - 进度条'
},
{
path: '/search',
title: 'Search - 搜索'
},
{
path: '/stepper',
title: 'Stepper - 步进器'
@ -181,6 +181,10 @@ module.exports = {
path: '/radio',
title: 'Radio - 单选框'
},
{
path: '/search',
title: 'Search - 搜索'
},
{
path: '/switch',
title: 'Switch - 开关'
@ -319,6 +323,10 @@ module.exports = {
title: 'Changelog',
noExample: true
},
{
path: '/built-in-style',
title: 'Built-in style'
},
{
path: '/theme',
title: 'Custom Theme',
@ -406,10 +414,6 @@ module.exports = {
path: '/progress',
title: 'Progress'
},
{
path: '/search',
title: 'Search'
},
{
path: '/stepper',
title: 'Stepper'
@ -463,6 +467,10 @@ module.exports = {
path: '/radio',
title: 'Radio'
},
{
path: '/search',
title: 'Search'
},
{
path: '/switch',
title: 'Switch'

View File

@ -1,19 +1,17 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './DocsApp';
import routes from './router.config';
import routes from './router';
import VantDoc from 'vant-doc';
import isMobile from './utils/is-mobile';
import { isMobile } from './utils';
import './components/nprogress.css';
Vue.use(VueRouter).use(VantDoc);
const routesConfig = routes();
const router = new VueRouter({
mode: 'hash',
base: '/zanui/vant/',
routes: routesConfig
routes: routes()
});
router.beforeEach((route, redirect, next) => {
@ -34,5 +32,5 @@ window.vueRouter = router;
new Vue({ // eslint-disable-line
render: h => h(App),
router,
el: '#app-container'
el: '#app'
});

View File

@ -3,15 +3,16 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-Equiv="Cache-Control" Content="no-cache" />
<meta http-Equiv="Pragma" Content="no-cache" />
<meta http-Equiv="Expires" Content="0" />
<link rel="shortcut icon" href="https://img.yzcdn.cn/zanui/vant/vant-2017-12-18.ico">
<title>Vant - 有赞移动端 Vue 组件库</title>
<script>window.Promise || document.write('<script src="//b.yzcdn.cn/huiyi/build/h5/js/pinkie.min.js"><\/script>');</script>
<script>window.Promise || document.write('<script src="//img.yzcdn.cn/huiyi/build/h5/js/pinkie.min.js"><\/script>');</script>
</head>
<body ontouchstart>
<div id="app-container">
<app></app>
</div>
<div id="app"></div>
</body>
</html>

View File

@ -1,11 +1,10 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './WapApp';
import routes from './router.config';
import routes from './router';
import Vant, { Lazyload } from 'packages';
import VantDoc from 'vant-doc';
import 'packages/vant-css/src/index.css';
import 'packages/vant-css/src/icon-local.css';
import 'vant-doc/src/helper/touch-simulator';
import './components/nprogress.css';
@ -17,18 +16,19 @@ Vue
lazyComponent: true
});
const routesConfig = routes(true);
const router = new VueRouter({
mode: 'hash',
base: '/zanui/vant/examples',
routes: routesConfig
routes: routes(true)
});
router.afterEach(() => {
if (router.currentRoute.name) {
window.scrollTo(0, 0);
}
Vue.nextTick(() => window.syncPath());
if (!router.currentRoute.redirectedFrom) {
Vue.nextTick(() => window.syncPath());
}
});
window.vueRouter = router;
@ -36,5 +36,5 @@ window.vueRouter = router;
new Vue({ // eslint-disable-line
render: h => h(App),
router,
el: '#app-container'
el: '#app'
});

View File

@ -22,28 +22,26 @@ const registerRoute = (isExample) => {
} else {
route.push({
path: `/${lang}`,
redirect: `/${lang}/component/intro`
redirect: `/${lang}/intro`
});
}
const navs = docConfig[lang].nav || [];
navs.forEach(nav => {
if (isExample && !nav.showInMobile) {
return;
}
if (nav.groups) {
nav.groups.forEach(group => {
group.list.forEach(page => addRoute(page, lang));
});
} else if (nav.children) {
nav.children.forEach(page => addRoute(page, lang));
} else {
addRoute(nav, lang);
}
});
function addRoute(page, lang) {
if (isExample && page.noExample) {
return;
}
const { path } = page;
if (path) {
const name = lang + '/' + path.replace('/', '');
@ -58,8 +56,11 @@ const registerRoute = (isExample) => {
route.push({
name,
component,
path: `/${lang}/component${path}`,
meta: { lang }
path: `/${lang}${path}`,
meta: {
lang,
name: page.title
}
});
}
}

View File

@ -2,9 +2,8 @@
* 同步父窗口和 iframe vue-router 状态
*/
import isMobile from './is-mobile';
import { setLang } from './lang';
import { iframeReady } from './iframe';
import { iframeReady, isMobile } from './';
window.syncPath = function(dir) {
const router = window.vueRouter;
@ -23,6 +22,7 @@ window.syncPath = function(dir) {
iframe.contentWindow.changePath(lang, currentDir);
});
}
setLang(lang);
} else if (isInIframe) {
window.top.changePath(lang, currentDir);
}

View File

@ -1,4 +1,4 @@
export function iframeReady(iframe, callback) {
function iframeReady(iframe, callback) {
const doc = iframe.contentDocument || iframe.contentWindow.document;
const interval = () => {
if (iframe.contentWindow.changePath) {
@ -16,3 +16,11 @@ export function iframeReady(iframe, callback) {
iframe.onload = interval;
}
}
const ua = navigator.userAgent.toLowerCase();
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
export {
isMobile,
iframeReady
};

View File

@ -1,7 +0,0 @@
const isMobile = (function() {
var platform = navigator.userAgent.toLowerCase();
return (/(android|bb\d+|meego).+mobile|kdtunion|weibo|m2oapp|micromessenger|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i).test(platform) ||
(/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i).test(platform.substr(0, 4));
})();
export default isMobile;

15486
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "0.12.9",
"version": "0.12.12",
"description": "A Vue.js 2.0 Mobile UI at YouZan",
"main": "lib/vant.js",
"style": "lib/vant-css/index.css",
@ -25,10 +25,10 @@
"deploy:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.prod.js",
"dist": "npm run bootstrap && node build/bin/build-lib.js",
"lint": "./node_modules/.bin/eslint ./packages --ext .js,.vue",
"test": "karma start test/unit/karma.conf.js --single-run",
"test:coverage": "open test/unit/coverage/lcov-report/index.html",
"test:watch": "karma start test/unit/karma.conf.js",
"test:single": "node ./test/unit/selector.js",
"test": "karma start test/karma.conf.js --single-run",
"test:coverage": "open test/coverage/lcov-report/index.html",
"test:watch": "karma start test/karma.conf.js",
"test:single": "node ./test/selector.js",
"release": "sh build/release.sh"
},
"repository": {
@ -44,34 +44,34 @@
"license": "MIT",
"dependencies": {
"babel-runtime": "6.x",
"vue-lazyload": "^1.1.4"
"vue-lazyload": "^1.2.1"
},
"peerDependencies": {
"vue": ">= 2.5.0"
},
"devDependencies": {
"autoprefixer": "^7.2.5",
"autoprefixer": "^8.1.0",
"avoriaz": "2.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-loader": "^7.1.3",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cache-loader": "^1.2.0",
"cache-loader": "^1.2.2",
"chai": "^4.1.2",
"codecov": "^3.0.0",
"cross-env": "^5.1.3",
"css-loader": "^0.28.9",
"dependency-tree": "^6.0.0",
"eslint": "^4.17.0",
"eslint-plugin-vue": "^4.2.2",
"css-loader": "^0.28.10",
"dependency-tree": "^6.0.1",
"eslint": "^4.18.2",
"eslint-plugin-vue": "^4.3.0",
"extract-text-webpack-plugin": "3.0.2",
"fast-vue-md-loader": "^1.0.3",
"friendly-errors-webpack-plugin": "^1.6.1",
"gh-pages": "^1.0.0",
"html-webpack-plugin": "^2.29.0",
"html-webpack-plugin": "^3.0.4",
"isparta-loader": "^2.0.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
@ -82,30 +82,29 @@
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^2.0.9",
"mocha": "^4.0.1",
"postcss": "^6.0.17",
"postcss": "^6.0.19",
"postcss-calc": "^6.0.0",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^2.0.10",
"postcss-loader": "^2.1.1",
"precss": "2.0.0",
"progress-bar-webpack-plugin": "^1.10.0",
"progress-bar-webpack-plugin": "^1.11.0",
"rimraf": "^2.5.4",
"shelljs": "^0.8.1",
"sinon": "^2.4.1",
"sinon-chai": "^2.12.0",
"style-loader": "^0.20.1",
"style-loader": "^0.20.2",
"uppercamelcase": "^3.0.0",
"url-loader": "^0.6.2",
"vant-doc": "1.0.3",
"url-loader": "^1.0.1",
"vant-doc": "1.0.4",
"vue": "^2.5.13",
"vue-loader": "^14.1.1",
"vue-router": "^3.0.1",
"vue-sfc-compiler": "^0.0.8",
"vue-style-loader": "^3.1.2",
"vue-style-loader": "^4.0.2",
"vue-template-compiler": "^2.5.13",
"vue-template-es2015-compiler": "^1.6.0",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.10.0",
"webpack": "^3.11.0",
"webpack-dev-server": "2.11.1",
"webpack-merge": "^4.1.1"
"webpack-merge": "^4.1.2"
}
}

View File

@ -126,6 +126,10 @@ export default create({
searchResult: {
type: Array,
default: () => []
},
telValidator: {
type: Function,
default: validateMobile
}
},
@ -233,7 +237,7 @@ export default create({
case 'name':
return value ? value.length <= 15 ? '' : $t('nameOverlimit') : $t('nameEmpty');
case 'tel':
return validateMobile(value) ? '' : $t('telWrong');
return this.telValidator(value) ? '' : $t('telWrong');
case 'area_code':
return value ? +value !== -1 ? '' : $t('areaWrong') : $t('areaEmpty');
case 'address_detail':

View File

@ -16,7 +16,7 @@
</template>
<script>
import { create } from '../utils';
import { create, isObj } from '../utils';
import Picker from '../picker';
export default create({
@ -42,7 +42,7 @@ export default create({
computed: {
listValid() {
return this.areaList && typeof this.areaList.province_list === 'object';
return this.areaList && isObj(this.areaList.province_list);
},
columns() {

View File

@ -12,7 +12,11 @@ export default create({
props: {
value: {},
disabled: Boolean
disabled: Boolean,
max: {
default: 0,
type: Number
}
},
watch: {

View File

@ -1,28 +1,23 @@
<template>
<div
class="van-checkbox"
:class="[
`van-checkbox--${shape}`,
{ 'van-checkbox--disabled': isDisabled }
]"
>
<span class="van-checkbox__input">
<input
v-model="currentValue"
type="checkbox"
class="van-checkbox__control"
:disabled="isDisabled"
>
<icon name="success" />
</span>
<span class="van-checkbox__label" @click="onClickLabel">
<div class="van-checkbox">
<icon
name="success"
class="van-checkbox__icon"
:class="[
`van-checkbox--${shape}`,
{ 'van-checkbox--disabled': isDisabled },
{ 'van-checkbox--checked': isChecked }
]"
@click="onClick"
/>
<span class="van-checkbox__label" @click="onClick('label')">
<slot />
</span>
</div>
</template>
<script>
import { create } from '../utils';
import { create, isDef } from '../utils';
import findParent from '../mixins/find-parent';
export default create({
@ -33,6 +28,10 @@ export default create({
props: {
value: {},
disabled: Boolean,
labelDisabled: {
type: Boolean,
default: false
},
name: [String, Number],
shape: {
type: String,
@ -46,32 +45,38 @@ export default create({
}
},
computed: {
// whether is in van-checkbox-group
isGroup() {
return !!this.findParentByName('van-checkbox-group');
},
data() {
this.findParentByName('van-checkbox-group');
return {};
},
computed: {
currentValue: {
get() {
return this.isGroup && this.parentGroup ? this.parentGroup.value.indexOf(this.name) !== -1 : this.value;
return this.parentGroup
? this.parentGroup.value.indexOf(this.name) !== -1
: this.value;
},
set(val) {
if (this.isGroup && this.parentGroup) {
const { parentGroup } = this;
if (parentGroup) {
const parentValue = this.parentGroup.value.slice();
if (val) {
if (parentGroup.max && parentValue.length >= parentGroup.max) {
return;
}
/* istanbul ignore else */
if (parentValue.indexOf(this.name) === -1) {
parentValue.push(this.name);
this.parentGroup.$emit('input', parentValue);
parentGroup.$emit('input', parentValue);
}
} else {
const index = parentValue.indexOf(this.name);
/* istanbul ignore else */
if (index !== -1) {
parentValue.splice(index, 1);
this.parentGroup.$emit('input', parentValue);
parentGroup.$emit('input', parentValue);
}
}
} else {
@ -84,19 +89,19 @@ export default create({
const { currentValue } = this;
if ({}.toString.call(currentValue) === '[object Boolean]') {
return currentValue;
} else if (currentValue !== null && currentValue !== undefined) {
} else if (isDef(currentValue)) {
return currentValue === this.name;
}
},
isDisabled() {
return (this.isGroup && this.parentGroup && this.parentGroup.disabled) || this.disabled;
return (this.parentGroup && this.parentGroup.disabled) || this.disabled;
}
},
methods: {
onClickLabel() {
if (!this.isDisabled) {
onClick(target) {
if (!this.isDisabled && !(target === 'label' && this.labelDisabled)) {
this.currentValue = !this.currentValue;
}
}

View File

@ -54,6 +54,10 @@ export default create({
tel: '',
name: ''
})
},
telValidator: {
type: Function,
default: validateMobile
}
},
@ -84,7 +88,7 @@ export default create({
case 'name':
return value ? value.length <= 15 ? '' : this.$t('nameOverlimit') : this.$t('nameEmpty');
case 'tel':
return validateMobile(value) ? '' : this.$t('telInvalid');
return this.telValidator(value) ? '' : this.$t('telInvalid');
}
},

View File

@ -34,7 +34,7 @@
:data="item"
/>
<div class="van-coupon-list__empty" v-if="!coupons.length && !disabledCoupons.length">
<img src="https://b.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png" >
<img src="https://img.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png" >
<p>{{ $t('empty') }}</p>
</div>
</div>

View File

@ -63,7 +63,7 @@ import TreeSelect from './tree-select';
import Uploader from './uploader';
import Waterfall from './waterfall';
const version = '0.12.9';
const version = '0.12.12';
const components = [
Actionsheet,
AddressEdit,

View File

@ -113,7 +113,7 @@ export default {
}
if (this.overlay) {
manager.openModal(this, {
manager.open(this, {
id: this._popupId,
dom: this.$el,
zIndex: context.plusKey('zIndex'),
@ -146,7 +146,7 @@ export default {
},
doAfterClose() {
manager.closeModal(this._popupId);
manager.close(this._popupId);
if (this.lockOnScroll) {
document.body.classList.remove('van-overflow-hidden');

View File

@ -2,68 +2,48 @@ import Vue from 'vue';
import Modal from './Modal';
import context from './context';
const modalDefaultConfig = {
const defaultConfig = {
className: '',
customStyle: {}
};
const manager = {
getModal() {
let { modal } = context;
if (!modal) {
const ModalConstructor = Vue.extend(Modal);
modal = new ModalConstructor({
el: document.createElement('div')
});
modal.$on('click', () => {
manager.onClickOverlay();
});
context.modal = modal;
}
return modal;
},
// close popup when click modal && closeOnClickOverlay is true
onClickOverlay() {
const { top } = context;
if (top) {
const { instance } = top;
if (instance && instance.closeOnClickOverlay) {
instance.close();
}
}
},
openModal(instance, config) {
export default {
open(vm, config) {
const { id, dom } = config;
const exist = context.stack.some(item => item.id === id);
/* istanbul ignore next */
if (!exist) {
const targetNode = dom && dom.parentNode && dom.parentNode.nodeType !== 11 ? dom.parentNode : document.body;
context.stack.push({ instance, id, config, targetNode });
this.updateModal();
context.stack.push({ vm, id, config, targetNode });
this.update();
};
},
closeModal(id) {
close(id) {
const { stack } = context;
if (stack.length) {
if (context.top.id === id) {
stack.pop();
this.updateModal();
this.update();
} else {
context.stack = stack.filter(item => item.id !== id);
}
}
},
updateModal() {
const modal = this.getModal();
update() {
let { modal } = context;
if (!modal) {
modal = new (Vue.extend(Modal))({
el: document.createElement('div')
});
modal.$on('click', this.onClick);
context.modal = modal;
}
if (modal.$el.parentNode) {
modal.visible = false;
@ -74,12 +54,21 @@ const manager = {
targetNode.appendChild(modal.$el);
Object.assign(modal, {
...modalDefaultConfig,
...defaultConfig,
...config,
visible: true
});
}
},
// close popup when click modal && closeOnClickOverlay is true
onClick() {
if (context.top) {
const { vm } = context.top;
if (vm) {
vm.$emit('click-overlay');
vm.closeOnClickOverlay && vm.close();
}
}
}
};
export default manager;

View File

@ -25,7 +25,7 @@
</template>
<script>
import { create } from '../utils';
import { create, isObj } from '../utils';
const DEFAULT_DURATION = 200;
const range = (num, arr) => Math.min(Math.max(num, arr[0]), arr[1]);
@ -147,11 +147,11 @@ export default create({
},
isDisabled(option) {
return typeof option === 'object' && option.disabled;
return isObj(option) && option.disabled;
},
getOptionText(option) {
return typeof option === 'object' && this.valueKey in option ? option[this.valueKey] : option;
return isObj(option) && this.valueKey in option ? option[this.valueKey] : option;
},
setIndex(index, userAction) {

View File

@ -5,6 +5,7 @@
position="bottom"
lock-on-scroll
prevent-scroll
:close-on-click-overlay="closeOnClickOverlay"
:get-container="getContainer"
>
<div class="van-sku-container">
@ -145,6 +146,7 @@ export default create({
resetStepperOnHide: Boolean,
resetSelectedSkuOnHide: Boolean,
disableStepperInput: Boolean,
closeOnClickOverlay: Boolean,
initialSku: {
type: Object,
default: () => ({})

View File

@ -79,9 +79,11 @@ export default create({
watch: {
value(val) {
val = this.correctValue(+val);
if (val !== this.currentValue) {
this.currentValue = val;
if (val !== '') {
val = this.correctValue(+val);
if (val !== this.currentValue) {
this.currentValue = val;
}
}
}
},
@ -99,8 +101,8 @@ export default create({
},
onInput(event) {
const val = +event.target.value;
this.currentValue = this.correctValue(val);
const { value } = event.target;
this.currentValue = value ? this.correctValue(+value) : value;
this.emitInput();
},

View File

@ -29,6 +29,10 @@ export default create({
props: {
autoplay: Number,
loop: {
type: Boolean,
default: true
},
initialSwipe: {
type: Number,
default: 0
@ -72,6 +76,12 @@ export default create({
initialSwipe() {
this.initialize();
},
autoplay(autoplay) {
if (!autoplay) {
clearTimeout(this.timer);
}
}
},
@ -146,6 +156,14 @@ export default create({
move(move = 0, offset = 0) {
const { active, count, swipes, deltaX, width } = this;
if (
!this.loop &&
((active === 0 && (offset > 0 || move < 0)) ||
(active === count - 1 && (offset < 0 || move > 0)))
) {
return;
}
if (move) {
if (active === -1) {
swipes[count - 1].offset = 0;
@ -184,9 +202,9 @@ export default create({
},
getDirection(touch) {
const distanceX = Math.abs(touch.clientX - this.startX);
const distanceY = Math.abs(touch.clientY - this.startY);
return distanceX > distanceY ? 'horizontal' : distanceX < distanceY ? 'vertical' : '';
const offsetX = Math.abs(touch.clientX - this.startX);
const offsetY = Math.abs(touch.clientY - this.startY);
return offsetX > offsetY ? 'horizontal' : offsetX < offsetY ? 'vertical' : '';
},
range(num, arr) {

View File

@ -1,5 +1,5 @@
<template>
<cell :title="title" class="van-switch-cell">
<cell :title="title" :border="border" class="van-switch-cell">
<van-switch v-bind="$props" @input="$emit('input', $event)" />
</cell>
</template>
@ -20,6 +20,7 @@ export default create({
props: {
title: String,
value: Boolean,
border: Boolean,
loading: Boolean,
disabled: Boolean
},

View File

@ -1,5 +1,6 @@
import Vue from 'vue';
import VueToast from './toast';
import { isObj } from '../utils';
const defaultOptions = {
type: 'text',
@ -10,7 +11,7 @@ const defaultOptions = {
position: 'middle',
forbidClick: false
};
const parseOptions = message => typeof message === 'object' ? message : { message };
const parseOptions = message => isObj(message) ? message : { message };
let queue = [];
let singleton = true;

View File

@ -8,10 +8,10 @@ import install from './install';
import Loading from '../loading';
export default function(sfc) {
sfc.mixins = sfc.mixins || [];
sfc.components = sfc.components || {};
sfc.install = sfc.install || install;
sfc.mixins = sfc.mixins || [];
sfc.mixins.push(i18n);
sfc.components = sfc.components || {};
sfc.components.icon = Icon;
sfc.components.loading = Loading;

View File

@ -1,12 +1,7 @@
import { isDef } from './';
import { isDef, isObj } from './';
const { hasOwnProperty } = Object.prototype;
function isObj(x) {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
function assignKey(to, from, key) {
const val = from[key];

View File

@ -7,6 +7,11 @@ function isDef(value) {
return value !== undefined && value !== null;
}
function isObj(x) {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
function get(object, path) {
const keys = path.split('.');
let result = object;
@ -30,6 +35,7 @@ function isAndroid() {
export {
get,
isObj,
isDef,
create,
isServer,

View File

@ -1,6 +1,6 @@
{
"name": "vant-css",
"version": "0.12.10",
"version": "0.12.12",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "vant-css",
"version": "0.12.10",
"version": "0.12.12",
"description": "vant css.",
"main": "lib/index.css",
"style": "lib/index.css",

View File

@ -49,6 +49,10 @@ module.exports = {
src: 'more-o.svg',
css: 'more-o'
},
{
src: 'info-o.svg',
css: 'info-o'
},
{
src: 'share.svg',
css: 'share'
@ -205,6 +209,10 @@ module.exports = {
src: 'arrow-left.svg',
css: 'arrow-left'
},
{
src: '搜索.svg',
css: 'search'
},
{
src: '成功.svg',
css: 'success'
@ -218,9 +226,25 @@ module.exports = {
css: 'add'
},
{
src: '选中.svg',
src: 'checked.svg',
css: 'checked'
},
{
src: 'warn.svg',
css: 'warn'
},
{
src: '清除搜索.svg',
css: 'clear'
},
{
src: 'underway.svg',
css: 'underway'
},
{
src: 'more.svg',
css: 'more'
},
{
src: '喜欢2.svg',
css: 'like'
@ -245,14 +269,6 @@ module.exports = {
src: '照片.svg',
css: 'photo'
},
{
src: '搜索.svg',
css: 'search'
},
{
src: '清除搜索.svg',
css: 'clear'
},
{
src: '微信支付.svg',
css: 'wechat'
@ -329,10 +345,6 @@ module.exports = {
src: '货到付款.svg',
css: 'cash-on-deliver'
},
{
src: '进行中.svg',
css: 'underway'
},
{
src: '电话.svg',
css: 'phone'
@ -368,10 +380,6 @@ module.exports = {
{
src: '热卖.svg',
css: 'hot-sale'
},
{
src: 'more.svg',
css: 'more'
}
]
};

View File

@ -4,7 +4,7 @@
font-style: normal;
font-weight: normal;
font-family: '<%= fontName %>';
src: url('https://b.yzcdn.cn/zanui/icon/<%= fontName %>.ttf') format('truetype');
src: url('https://img.yzcdn.cn/zanui/icon/<%= fontName %>.ttf') format('truetype');
}
.van-icon {

View File

@ -69,6 +69,10 @@
}
&--loading {
.van-loading {
margin: 0 auto;
}
.van-button__text {
display: none;
}

View File

@ -6,70 +6,45 @@ $van-checkbox-size: 20px;
overflow: hidden;
user-select: none;
.van-icon-success {
color: $white;
display: block;
&__icon,
&__label {
display: inline-block;
vertical-align: middle;
line-height: $van-checkbox-size;
}
&__icon {
font-size: 12px;
color: transparent;
text-align: center;
pointer-events: none;
border: 1px solid #aaa;
width: $van-checkbox-size;
height: $van-checkbox-size;
box-sizing: border-box;
&::before {
margin: 0 auto;
line-height: $van-checkbox-size;
}
}
&__input,
&__label {
display: inline-block;
vertical-align: middle;
}
&__input {
position: relative;
height: $van-checkbox-size;
}
&__control {
position: absolute;
top: 0;
left: 0;
opacity: 0;
margin: 0;
width: 100%;
height: 100%;
}
&__label {
margin-left: 10px;
line-height: $van-checkbox-size;
}
&--round {
.van-icon-success {
border-radius: 100%;
}
border-radius: 100%;
}
&__control:checked + .van-icon-success {
&--checked {
color: #fff;
border-color: $green;
background-color: $green;
}
&--disabled {
.van-icon-success {
color: $background-color;
border-color: $gray-light;
background-color: currentColor;
}
color: $background-color;
border-color: $gray-light;
background-color: currentColor;
}
.van-checkbox__control:checked + .van-icon-success {
border-color: $gray-light;
background-color: $gray-light;
}
&--disabled&--checked {
border-color: $gray-light;
background-color: $gray-light;
}
}

View File

@ -1,20 +1,14 @@
@import "../mixins/border-retina.css";
.van-hairline {
&,
&--top,
&--left,
&--right,
&--bottom,
&--top-bottom,
&--surround {
position: relative;
[class*='van-hairline'] {
position: relative;
&::after {
@mixin hairline;
}
&::after {
@mixin hairline;
}
}
.van-hairline {
&--top::after {
border-top-width: 1px;
}

View File

@ -139,7 +139,7 @@
display: flex;
margin-left: -1px; /* hack for flex space */
text-align: center;
padding-right: 16px;
margin-left: -16px;
flex-direction: column;
justify-content: center;
background-image: linear-gradient(45deg, #ff6868, #ff8c8c);
@ -158,7 +158,6 @@
margin: 0;
font-size: 14px;
font-weight: 300;
max-width: 90px;
@mixin ellipsis;
}
}

View File

@ -77,7 +77,9 @@
width: 100%;
resize: none;
&[disabled] {
&:disabled {
opacity: 1;
color: $gray-darker;
background-color: transparent;
}
}

View File

@ -2,5 +2,5 @@
font-style: normal;
font-weight: normal;
font-family: 'vant-icon';
src: url('./vant-icon-dc7d92.ttf') format('truetype');
src: url('./vant-icon-4c3245.ttf') format('truetype');
}

View File

@ -4,7 +4,7 @@
font-style: normal;
font-weight: normal;
font-family: 'vant-icon';
src: url('https://b.yzcdn.cn/zanui/icon/vant-icon-dc7d92.ttf') format('truetype');
src: url('https://img.yzcdn.cn/zanui/icon/vant-icon-4c3245.ttf') format('truetype');
}
.van-icon {
@ -171,147 +171,153 @@
.van-icon-hot:before {
content: "\F02C";
}
.van-icon-like-o:before {
.van-icon-info-o:before {
content: "\F02D";
}
.van-icon-like:before {
.van-icon-like-o:before {
content: "\F02E";
}
.van-icon-location:before {
.van-icon-like:before {
content: "\F02F";
}
.van-icon-logistics:before {
.van-icon-location:before {
content: "\F030";
}
.van-icon-member-day-privilege:before {
.van-icon-logistics:before {
content: "\F031";
}
.van-icon-more-o:before {
.van-icon-member-day-privilege:before {
content: "\F032";
}
.van-icon-more:before {
.van-icon-more-o:before {
content: "\F033";
}
.van-icon-new-arrival:before {
.van-icon-more:before {
content: "\F034";
}
.van-icon-new:before {
.van-icon-new-arrival:before {
content: "\F035";
}
.van-icon-other-pay:before {
.van-icon-new:before {
content: "\F036";
}
.van-icon-passed:before {
.van-icon-other-pay:before {
content: "\F037";
}
.van-icon-password-not-view:before {
.van-icon-passed:before {
content: "\F038";
}
.van-icon-password-view:before {
.van-icon-password-not-view:before {
content: "\F039";
}
.van-icon-pause:before {
.van-icon-password-view:before {
content: "\F03A";
}
.van-icon-peer-pay:before {
.van-icon-pause:before {
content: "\F03B";
}
.van-icon-pending-deliver:before {
.van-icon-peer-pay:before {
content: "\F03C";
}
.van-icon-pending-evaluate:before {
.van-icon-pending-deliver:before {
content: "\F03D";
}
.van-icon-pending-orders:before {
.van-icon-pending-evaluate:before {
content: "\F03E";
}
.van-icon-pending-payment:before {
.van-icon-pending-orders:before {
content: "\F03F";
}
.van-icon-phone:before {
.van-icon-pending-payment:before {
content: "\F040";
}
.van-icon-photo:before {
.van-icon-phone:before {
content: "\F041";
}
.van-icon-photograph:before {
.van-icon-photo:before {
content: "\F042";
}
.van-icon-play:before {
.van-icon-photograph:before {
content: "\F043";
}
.van-icon-point-gift:before {
.van-icon-play:before {
content: "\F044";
}
.van-icon-points-mall:before {
.van-icon-point-gift:before {
content: "\F045";
}
.van-icon-points:before {
.van-icon-points-mall:before {
content: "\F046";
}
.van-icon-qr-invalid:before {
.van-icon-points:before {
content: "\F047";
}
.van-icon-qr:before {
.van-icon-qr-invalid:before {
content: "\F048";
}
.van-icon-question:before {
.van-icon-qr:before {
content: "\F049";
}
.van-icon-receive-gift:before {
.van-icon-question:before {
content: "\F04A";
}
.van-icon-records:before {
.van-icon-receive-gift:before {
content: "\F04B";
}
.van-icon-search:before {
.van-icon-records:before {
content: "\F04C";
}
.van-icon-send-gift:before {
.van-icon-search:before {
content: "\F04D";
}
.van-icon-setting:before {
.van-icon-send-gift:before {
content: "\F04E";
}
.van-icon-share:before {
.van-icon-setting:before {
content: "\F04F";
}
.van-icon-shop-collect:before {
.van-icon-share:before {
content: "\F050";
}
.van-icon-shop:before {
.van-icon-shop-collect:before {
content: "\F051";
}
.van-icon-shopping-cart:before {
.van-icon-shop:before {
content: "\F052";
}
.van-icon-sign:before {
.van-icon-shopping-cart:before {
content: "\F053";
}
.van-icon-stop:before {
.van-icon-sign:before {
content: "\F054";
}
.van-icon-success:before {
.van-icon-stop:before {
content: "\F055";
}
.van-icon-tosend:before {
.van-icon-success:before {
content: "\F056";
}
.van-icon-underway:before {
.van-icon-tosend:before {
content: "\F057";
}
.van-icon-upgrade:before {
.van-icon-underway:before {
content: "\F058";
}
.van-icon-value-card:before {
.van-icon-upgrade:before {
content: "\F059";
}
.van-icon-wap-home:before {
.van-icon-value-card:before {
content: "\F05A";
}
.van-icon-wap-nav:before {
.van-icon-wap-home:before {
content: "\F05B";
}
.van-icon-wechat:before {
.van-icon-wap-nav:before {
content: "\F05C";
}
.van-icon-warn:before {
content: "\F05D";
}
.van-icon-wechat:before {
content: "\F05E";
}

View File

@ -77,7 +77,7 @@
}
.van-loading__spinner--gradient-circle {
background-image: url('https://b.yzcdn.cn/vant/gradient-circle-black.png');
background-image: url('https://img.yzcdn.cn/vant/gradient-circle-black.png');
}
.van-loading__spinner--spinner {
@ -96,7 +96,7 @@
}
.van-loading__spinner--gradient-circle {
background-image: url('https://b.yzcdn.cn/vant/gradient-circle-white.png');
background-image: url('https://img.yzcdn.cn/vant/gradient-circle-white.png');
}
.van-loading__spinner--spinner {

View File

@ -1,8 +1,6 @@
module.exports = {
plugins: [
require('postcss-easy-import')({
extensions: ['pcss', 'css']
}),
require('postcss-easy-import')(),
require('precss')(),
require('postcss-calc')(),
require('autoprefixer')({

View File

@ -0,0 +1,6 @@
<template>
<van-badge-group>
<van-badge title="热销榜" info="8" />
<van-badge title="手握寿司" info="199" />
</van-badge-group>
</template>

View File

@ -0,0 +1,22 @@
<template>
<van-checkbox-group v-model="result" :max="max">
<van-checkbox v-for="(item, index) in list" :key="index" :name="item" :disabled="index === 2">复选框{{ item }}</van-checkbox>
</van-checkbox-group>
</template>
<script>
export default {
data() {
return {
list: [
'a',
'b',
'c',
'd'
],
result: ['a', 'b'],
max: 0
};
}
};
</script>

16
test/components/field.vue Normal file
View File

@ -0,0 +1,16 @@
<template>
<van-field @click-icon="onIconClick" @blur="$emit('blur')">
<div slot="icon">icon</div>
</van-field>
</template>
<script>
export default {
props: {
onIconClick: {
type: Function,
default: () => {}
}
}
};
</script>

View File

@ -0,0 +1,16 @@
<template>
<van-goods-action>
<van-goods-action-mini-btn icon="chat">
客服
</van-goods-action-mini-btn>
<van-goods-action-mini-btn icon="cart" url="http://www.youzan.com">
购物车
</van-goods-action-mini-btn>
<van-goods-action-big-btn>
加入购物车
</van-goods-action-big-btn>
<van-goods-action-big-btn primary url="http://www.youzan.com">
立即购买
</van-goods-action-big-btn>
</van-goods-action>
</template>

View File

@ -12,15 +12,7 @@
</template>
<script>
import Tab from 'packages/tab';
import Tabs from 'packages/tabs';
export default {
components: {
'van-tab': Tab,
'van-tabs': Tabs
},
props: {
active: [String, Number]
}

View File

@ -5,12 +5,12 @@
</template>
<script>
import NoticeBar from 'packages/notice-bar';
export default {
components: {
[NoticeBar.name]: NoticeBar
},
props: ['speed', 'text', 'mode', 'delay']
props: {
speed: Number,
text: String,
mode: String,
delay: Number
}
};
</script>

View File

@ -0,0 +1,13 @@
<template>
<keep-alive>
<van-number-keyboard v-if="showKeyboard" />
</keep-alive>
</template>
<script>
export default {
props: {
showKeyboard: Boolean
}
};
</script>

View File

@ -4,17 +4,9 @@
<van-radio name="2">单选框2</van-radio>
</van-radio-group>
</template>
<script>
import Radio from 'packages/radio';
import RadioGroup from 'packages/radio-group';
export default {
components: {
'van-radio': Radio,
'van-radio-group': RadioGroup
},
data() {
return {
radio: '1'

View File

@ -11,15 +11,3 @@
</van-col>
</van-row>
</template>
<script>
import Row from 'packages/row';
import Col from 'packages/col';
export default {
components: {
'van-row': Row,
'van-col': Col
}
};
</script>

View File

@ -8,15 +8,7 @@
</template>
<script>
import Steps from 'packages/steps';
import Step from 'packages/step';
export default {
components: {
'van-step': Step,
'van-steps': Steps
},
data() {
return {
active: 1

View File

@ -2,7 +2,7 @@
<van-tabbar v-model="active" @change="onChange">
<van-tabbar-item icon="shop">
<span>自定义</span>
<img slot="icon" :src="active === 0 ? icon.active : icon.normal" />
<img slot="icon" :src="active === 0 ? icon.active : icon.normal" >
</van-tabbar-item>
<van-tabbar-item icon="chat">标签</van-tabbar-item>
<van-tabbar-item icon="chat">标签</van-tabbar-item>
@ -11,15 +11,7 @@
</template>
<script>
import Tabbar from 'packages/tabbar';
import TabbarItem from 'packages/tabbar-item';
export default {
components: {
[Tabbar.name]: Tabbar,
[TabbarItem.name]: TabbarItem
},
data() {
return {
active: 0,

Some files were not shown because too many files have changed in this diff Show More