Merge branch 'dev' of https://github.com/youzan/vant into dev

This commit is contained in:
陈嘉涵 2017-12-21 09:23:37 +08:00
commit 5426184607
23 changed files with 366 additions and 1401 deletions

View File

@ -1,6 +1,6 @@
{
"presets": [["env", { "modules": false, "loose": true }]],
"plugins": ["transform-vue-jsx", "transform-runtime", "transform-object-rest-spread"],
"plugins": ["transform-runtime", "transform-object-rest-spread"],
"env": {
"commonjs": {
"presets": [["env", { "modules": "commonjs", "loose": true }]]

View File

@ -3,7 +3,7 @@
* Steps:
* 1. 代码格式校验
* 2. 构建 JS 入口文件
* 4. 构建每个组件对应的 [component].js
* 3. 构建每个组件对应的 [component].js
* 4. 构建 vant-css
* 5. 打包 JS 文件vant.js && vant.min.js
* 6. 生成每个组件目录下的 style 入口
@ -12,9 +12,9 @@
const chalk = require('chalk');
require('shelljs/global');
// 1. lint
log('Starting', 'lint');
exec('npm run lint --silent');
// 1. lint
log('Starting', 'lint');
exec('npm run lint --silent');
log('Finished', 'lint');
// 2. build entry

View File

@ -5,12 +5,10 @@
{{ $t('button1') }}
</van-button>
<van-button @touchstart.native.stop="showKeyboard = false">
{{ $t('button2') }}
</van-button>
<van-number-keyboard
:show="showKeyboard"
:closeButtonText="$t('close')"
extraKey="."
@blur="showKeyboard = false"
@input="onInput"
@delete="onDelete"
@ -24,11 +22,13 @@ export default {
i18n: {
'zh-CN': {
button1: '弹出键盘',
button2: '收起键盘'
button2: '收起键盘',
close: '完成'
},
'en-US': {
button1: 'Show Keyboard',
button2: 'Hide Keyboard'
button2: 'Hide Keyboard',
close: 'Close'
}
},

View File

@ -16,12 +16,10 @@ Vue.use(NumberKeyboard);
Show Keyboard
</van-button>
<van-button @touchstart.native.stop="showKeyboard = false">
Hide Keyboard
</van-button>
<van-number-keyboard
extraKey="."
:show="showKeyboard"
closeButtonText="Close"
@blur="showKeyboard = false"
@input="onInput"
@delete="onDelete"
@ -53,10 +51,12 @@ export default {
|-----------|-----------|-----------|-------------|-------------|
| show | Whether to show keyboard | `Boolean` | - | - |
| title | Keyboard title | `String` | - | - |
| extraKey | Content of bottom left key | `String` | `''` | - |
| zIndex | Keyboard z-index | `Number` | `100` | - |
| extraKey | Content of bottom left key | `String` | `''` | - |
| closeButtonText | Close button text | `String` | `-` | - |
| transition | Whether to show transition animation | `Boolean` | `true` | - |
| showDeleteKey | Whether to show delete button | `Boolean` | `true` | - |
| hideOnClickOutside | Whether to hide keyboard when click outside | `Boolean` | `true` | - |
### Event

View File

@ -2,7 +2,7 @@
### 使用指南
``` javascript
```javascript
import { Area } from 'vant';
Vue.use(Area);
@ -12,25 +12,23 @@ Vue.use(Area);
#### 基础用法
要初始化一个`Area`组件,你需要传入一个`areaList`属性,`areaList`数据格式具体可看下面数据格式章节
要初始化一个`Area`组件,你需要传入一个`areaList`属性,`areaList`数据格式具体可看下面数据格式章节
```html
<van-area :areaList="areaList" />
```
#### 选中省市县
如果想选中某个省市县,需要传入一个`value`属性,绑定对应的省市县`code`
如果想选中某个省市县,需要传入一个`value`属性,绑定对应的省市县`code`
```html
<van-area :areaList="areaList" value="110101" />
```
#### 配置显示列
可以通过`columnsNum`属性配置省市县显示的列数,默认情况下会显示省市县,当你设置为`2`,则只会显示省市选择
可以通过`columnsNum`属性配置省市县显示的列数,默认情况下会显示省市县,当你设置为`2`,则只会显示省市选择
```html
<van-area :areaList="areaList" :columnsNum="2" title="标题" />
@ -38,29 +36,30 @@ Vue.use(Area);
### API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| value | 当前选中的省市区`code` | `String` | - | - |
| title | 顶部栏标题 | `String` | `''` | - |
| areaList | 省市县数据,必须与`province_list``city_list``county_list`为key | `Object` | - | - |
| columnsNum | 省市县显示列数3-省市县2-省市1-省 | `String`,`Number` | 3 | - |
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
| ---------- | ------------------------------------------------------------------- | ----------------- | ------ | ------ |
| value | 当前选中的省市区`code` | `String` | - | - |
| title | 顶部栏标题 | `String` | `''` | - |
| areaList | 省市县数据,必须与`province_list``city_list``county_list` key | `Object` | - | - |
| columnsNum | 省市县显示列数3-省市县2-省市1-省 | `String`,`Number` | 3 | - |
### Event
| 事件名称 | 说明 | 回调参数 |
|-----------|-----------|-----------|
| confirm | 点击右上方完成按钮 | 一个数组参数,具体格式看下方数据格式章节 |
| cancel | 点击取消按钮时 | - |
| 事件名称 | 说明 | 回调参数 |
| -------- | ------------------ | ---------------------------------------- |
| confirm | 点击右上方完成按钮 | 一个数组参数,具体格式看下方数据格式章节 |
| cancel | 点击取消按钮时 | - |
### 数据格式
#### 省市县列表数据格式
整体是一个Object包含 `province_list`, `city_list`, `county_list` 三个key。
整体是一个 Object包含 `province_list`, `city_list`, `county_list` 三个 key。
每项以省市区编码作为key省市区名字作为value。编码为6位数字前两位代表省份中间两位代表城市后两位代表区县以0补足6位。如北京编码为 `11`以零补足6位`110000`
每项以省市区编码作为 key省市区名字作为 value。编码为 6 位数字,前两位代表省份,中间两位代表城市,后两位代表区县,以 0 补足 6 位。如北京编码为 `11`,以零补足 6 位,为 `110000`
`AreaList`具体格式如下:
```javascript
{
province_list: {
@ -91,18 +90,24 @@ Vue.use(Area);
完整数据见 [Area.json](https://github.com/youzan/vant/blob/dev/docs/demos/mock/area.json)
#### 点击完成时返回的数据格式
返回的数据整体为一个数组,数组内包含 `columnsNum` 个数据, 每个数据对应一列选项中被选中的数据。
`code` 代表被选中的地区编码, `name` 代表被选中的地区名称
```javascript
[{
code: '110000',
name: '北京市'
}, {
code: '110100',
name: '北京市'
},{
code: '110101',
name: '东城区'
}]
[
{
code: '110000',
name: '北京市'
},
{
code: '110100',
name: '北京市'
},
{
code: '110101',
name: '东城区'
}
];
```

View File

@ -16,12 +16,10 @@ Vue.use(NumberKeyboard);
弹出键盘
</van-button>
<van-button @touchstart.native.stop="showKeyboard = false">
收起键盘
</van-button>
<van-number-keyboard
extraKey="."
:show="showKeyboard"
closeButtonText="完成"
@blur="showKeyboard = false"
@input="onInput"
@delete="onDelete"
@ -53,10 +51,12 @@ export default {
|-----------|-----------|-----------|-------------|-------------|
| show | 是否显示键盘 | `Boolean` | - | - |
| title | 键盘标题 | `String` | - | - |
| extraKey | 左下角按键内容 | `String` | `''` | - |
| zIndex | 键盘 z-index | `Number` | `100` | - |
| extraKey | 左下角按键内容 | `String` | `''` | - |
| closeButtonText | 关闭按钮文字,空则不展示 | `String` | `-` | - |
| transition | 是否开启过场动画 | `Boolean` | `true` | - |
| showDeleteKey | 是否展示删除按钮 | `Boolean` | `true` | - |
| hideOnClickOutside | 点击外部时是否收起键盘 | `Boolean` | `true` | - |
### Event

View File

@ -1,16 +1,12 @@
{
"name": "vant",
"version": "0.11.13",
"description": "有赞vue wap组件库",
"description": "A Vue.js 2.0 Mobile UI at YouZan",
"main": "lib/vant.js",
"style": "lib/vant-css/index.css",
"unpkg": "lib/index.js",
"typings": "types/index.d.ts",
"files": [
"lib",
"src",
"packages"
],
"files": ["lib", "packages"],
"scripts": {
"bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../",
"dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js --content-base ./",
@ -24,8 +20,7 @@
"deploy:cdn": "superman cdn /zanui/vant docs/dist/*.js docs/dist/*.css && superman cdn /zanui/vant/async_en-US docs/dist/async_en-US/*.js && superman cdn /zanui/vant/async_zh-CN docs/dist/async_zh-CN/*.js",
"deploy:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.prod.js",
"dist": "node build/bin/build-lib.js",
"clean": "rimraf lib && rimraf packages/*/lib",
"lint": "felint lint src/**/*.js packages/**/*.{js,vue} build/**/*.js",
"lint": "./node_modules/.bin/eslint ./packages --ext .js --ext .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",
@ -36,11 +31,7 @@
"type": "git",
"url": "git@github.com:youzan/vant.git"
},
"keywords": [
"youzan",
"vue",
"component"
],
"keywords": ["youzan", "vue", "component"],
"author": "youzanfe",
"license": "MIT",
"dependencies": {
@ -55,32 +46,23 @@
"avoriaz": "2.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.2",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cache-loader": "^1.2.0",
"chai": "^4.1.2",
"cheerio": "^0.22.0",
"codecov": "^3.0.0",
"cross-env": "^5.1.1",
"css-loader": "^0.28.7",
"dependency-tree": "^5.12.0",
"eslint": "^4.13.1",
"eslint-plugin-vue": "^2.1.0",
"extract-text-webpack-plugin": "3.0.2",
"fast-vue-md-loader": "^1.0.3",
"felint": "^0.5.0-alpha.3",
"file-save": "^0.2.0",
"friendly-errors-webpack-plugin": "^1.6.1",
"gh-pages": "^1.0.0",
"gulp": "^3.9.1",
"gulp-cssmin": "^0.2.0",
"gulp-postcss": "^7.0.0",
"gulp-util": "^3.0.8",
"html-webpack-plugin": "^2.29.0",
"isparta-loader": "^2.0.0",
"karma": "^1.7.1",
@ -89,11 +71,8 @@
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon-chai": "^1.3.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^2.0.9",
"markdown-it": "^8.4.0",
"markdown-it-container": "^2.0.0",
"mocha": "^4.0.1",
"postcss": "^6.0.14",
"postcss-calc": "^6.0.0",
@ -102,7 +81,7 @@
"precss": "2.0.0",
"progress-bar-webpack-plugin": "^1.10.0",
"rimraf": "^2.5.4",
"run-sequence": "^2.1.0",
"shelljs": "^0.7.8",
"sinon": "^2.4.1",
"sinon-chai": "^2.12.0",
"style-loader": "^0.19.1",

View File

@ -72,6 +72,7 @@
</template>
<script>
/* eslint-disable camelcase */
import { create } from '../utils';
import Field from '../field';
import Cell from '../cell';
@ -149,7 +150,7 @@ export default create({
this.isEdit = !!val.id;
},
deep: true
},
}
},
computed: {

View File

@ -1,26 +1,21 @@
<template>
<div class="van-area">
<picker
ref="picker"
showToolbar
:title="title"
valueKey="name"
:columns="areaColumns"
@change="onChange"
@confirm="$emit('confirm', $event)"
@cancel="$emit('cancel', $event)"
/>
</div>
<picker
class="van-area"
ref="picker"
showToolbar
valueKey="name"
:title="title"
:columns="columns"
@change="onChange"
@confirm="$emit('confirm', $event)"
@cancel="$emit('cancel', $event)"
/>
</template>
<script>
import { create } from '../utils';
import Picker from '../picker';
const PROVINCE_TYPE = 'provice';
const CITY_TYPE = 'city';
const COUNTY_TYPE = 'county';
export default create({
name: 'van-area',
@ -40,52 +35,33 @@ export default create({
},
computed: {
DEFAULT_PROVINCE() {
return {
code: '-1',
name: this.$t('province')
};
},
DEFAULT_CITY() {
return {
code: '-1',
name: this.$t('city')
};
},
DEFAULT_COUNTY() {
return {
code: '-1',
name: this.$t('district')
};
},
areaColumns() {
const areaList = this.areaList;
if (!areaList || (areaList && typeof areaList.province_list !== 'object')) return [];
columns() {
const columns = [];
const curValue = this.value || '';
const { columnsNum } = this;
const { areaList } = this;
if (!areaList || typeof areaList.province_list !== 'object') {
return columns;
}
const code = this.value || '';
const columnsNum = +this.columnsNum;
columns.push({
values: [this.DEFAULT_PROVINCE].concat(this.computedAreaList(PROVINCE_TYPE)),
className: 'van-area__province',
defaultIndex: this.getAreaIndex(PROVINCE_TYPE, curValue)
values: this.getList('province'),
defaultIndex: this.getIndex('province', code)
});
if (+columnsNum > 1) {
if (columnsNum > 1) {
columns.push({
values: [this.DEFAULT_CITY].concat(this.computedAreaList(CITY_TYPE, curValue.slice(0, 2))),
className: 'van-area__city',
defaultIndex: this.getAreaIndex(CITY_TYPE, curValue)
values: this.getList('city', code.slice(0, 2)),
defaultIndex: this.getIndex('city', code)
});
}
if (+columnsNum > 2) {
if (columnsNum > 2) {
columns.push({
values: [this.DEFAULT_COUNTY].concat(this.computedAreaList(COUNTY_TYPE, curValue.slice(0, 4))),
className: 'van-area__county',
defaultIndex: this.getAreaIndex(COUNTY_TYPE, curValue)
values: this.getList('county', code.slice(0, 4)),
defaultIndex: this.getIndex('county', code)
});
}
@ -95,37 +71,40 @@ export default create({
methods: {
// `code`
computedAreaList(type, code) {
const result = [];
const curAreaList = this.areaList;
const areaList = type === PROVINCE_TYPE
? curAreaList.province_list
: (type === CITY_TYPE ? curAreaList.city_list : curAreaList.county_list);
getList(type, code) {
const { areaList } = this;
const list =
type === 'province'
? areaList.province_list
: type === 'city' ? areaList.city_list : areaList.county_list;
for (const i in areaList) {
//
//
if (type === PROVINCE_TYPE || (code && i.slice(0, code.length) === code)) {
result.push({
code: i,
name: areaList[i]
});
}
let result = Object.keys(list).map(code => ({
code,
name: list[code]
}));
if (type !== 'province' && code) {
result = result.filter(item => item.code.indexOf(code) === 0);
}
result.unshift({
code: '-1',
name: this.$t(type)
});
return result;
},
//
getAreaIndex(type, code) {
const compareNum = type === PROVINCE_TYPE
? 2
: (type === CITY_TYPE ? 4 : 6);
const areaList = this.computedAreaList(type, code.slice(0, compareNum - 2));
getIndex(type, code) {
const compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
const areaList = this.getList(type, code.slice(0, compareNum - 2));
for (let i = 0; i < areaList.length; i++) {
if (+areaList[i].code.slice(0, compareNum) === +code.slice(0, compareNum)) {
return i + 1;
if (
+areaList[i].code.slice(0, compareNum) === +code.slice(0, compareNum)
) {
return i;
}
}
@ -136,25 +115,15 @@ export default create({
const code = values[index].code;
//
if (index === 0) {
picker.setColumnValues(
1,
[this.DEFAULT_CITY].concat(this.computedAreaList(CITY_TYPE, code.slice(0, 2)))
);
picker.setColumnValues(
2,
[this.DEFAULT_COUNTY].concat(this.computedAreaList(COUNTY_TYPE, code.slice(0, 4)))
);
picker.setColumnValues(1, this.getList('city', code.slice(0, 2)));
picker.setColumnValues(2, this.getList('county', code.slice(0, 4)));
} else if (index === 1) {
picker.setColumnValues(
2,
[this.DEFAULT_COUNTY].concat(this.computedAreaList(COUNTY_TYPE, code.slice(0, 4)))
);
picker.setColumnValues(2, this.getList('county', code.slice(0, 4)));
}
},
getValues() {
const { picker } = this.$refs;
return picker ? picker.getValues() : [];
return this.$refs.picker ? this.$refs.picker.getValues() : [];
}
}
});

View File

@ -14,7 +14,7 @@
import { create } from '../utils';
import Picker from '../picker';
const isValidDate = date => Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date.getTime());
const isValidDate = date => Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
export default create({
name: 'van-datetime-picker',

View File

@ -58,7 +58,7 @@ export default {
vanArea: {
province: 'Province',
city: 'City',
district: 'District'
county: 'District'
},
vanAddressEdit: {
areaTitle: 'Area',

View File

@ -61,7 +61,7 @@ export default {
vanArea: {
province: '选择省份',
city: '选择城市',
district: '选择地区'
county: '选择地区'
},
vanAddressEdit: {
areaTitle: '收件地区',

View File

@ -9,12 +9,18 @@
@touchend="blurKey"
@touchcancel="blurKey"
@animationend="onAnimationEnd"
@webkitAnimationEnd="onAnimationEnd"
>
<div class="van-number-keyboard__title van-hairline--top" v-if="title">
<div class="van-number-keyboard__title van-hairline--top" v-if="title || closeButtonText">
<span>{{ title }}</span>
<span
class="van-number-keyboard__close"
v-text="closeButtonText"
@click="blurKeyboard"
/>
</div>
<i
v-for="(key, index) in keys"
<i
v-for="(key, index) in keys"
v-text="key"
:data-key="index"
class="van-hairline"
@ -35,6 +41,11 @@ export default create({
props: {
show: Boolean,
closeButtonText: String,
theme: {
type: String,
default: 'default'
},
extraKey: {
type: String,
default: ''
@ -51,6 +62,10 @@ export default create({
showDeleteKey: {
type: Boolean,
default: true
},
hideOnClickOutside: {
type: Boolean,
default: true
}
},
@ -103,7 +118,7 @@ export default create({
methods: {
handler(action) {
if (action !== this.handlerStatus) {
if (action !== this.handlerStatus && this.hideOnClickOutside) {
this.handlerStatus = action;
document.body[(action ? 'add' : 'remove') + 'EventListener']('touchstart', this.blurKeyboard);
}

View File

@ -79,7 +79,8 @@ export default create({
const pageCount = this.computedPageCount;
// Default page limits
let startPage = 1, endPage = pageCount;
let startPage = 1;
let endPage = pageCount;
const isMaxSized = this.showPageSize !== undefined && this.showPageSize < pageCount;
// recompute if showPageSize
@ -97,19 +98,19 @@ export default create({
// Add page number links
for (let number = startPage; number <= endPage; number++) {
let page = this.makePage(number, number, number === this.value);
const page = this.makePage(number, number, number === this.value);
pages.push(page);
}
// Add links to move between page sets
if (isMaxSized && this.showPageSize > 0 && this.forceEllipses) {
if (startPage > 1) {
let previousPageSet = this.makePage(startPage - 1, '...', false);
const previousPageSet = this.makePage(startPage - 1, '...', false);
pages.unshift(previousPageSet);
}
if (endPage < pageCount) {
let nextPageSet = this.makePage(endPage + 1, '...', false);
const nextPageSet = this.makePage(endPage + 1, '...', false);
pages.push(nextPageSet);
}
}

View File

@ -41,7 +41,9 @@ export default create({
currentValue: {
get() {
return this.isGroup && this.parentGroup ? this.parentGroup.value : this.value;
return this.isGroup && this.parentGroup
? this.parentGroup.value
: this.value;
},
set(val) {
@ -55,8 +57,8 @@ export default create({
isDisabled() {
return this.isGroup && this.parentGroup
? this.parentGroup.disabled || this.disabled
: this.disabled;
? this.parentGroup.disabled || this.disabled
: this.disabled;
}
},

View File

@ -151,7 +151,7 @@ export default create({
width: `${tab.offsetWidth || 0}px`,
transform: `translate3d(${tab.offsetLeft || 0}px, 0, 0)`,
transitionDuration: `${this.duration}s`
}
};
});
},
@ -197,7 +197,7 @@ export default create({
if (++count < frames) {
raf(animate);
}
}
};
animate();
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable */
export default function email(value) {
const reg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
return reg.test(value);

View File

@ -14,7 +14,21 @@
text-align: center;
color: $gray-dark;
font-size: 12px;
line-height: 25px;
height: 30px;
line-height: 30px;
position: relative;
}
&__close {
right: 0;
color: $blue;
font-size: 14px;
padding: 0 15px;
position: absolute;
&:active {
background-color: $active-color;
}
}
i {

View File

@ -18,7 +18,7 @@ function getWebpackConfig(testFileName) {
options: {
babel: {
presets: ['env'],
plugins: ['transform-runtime', 'transform-vue-jsx']
plugins: ['transform-runtime']
},
vue: {
autoprefixer: false,

View File

@ -14,7 +14,7 @@ module.exports = function(config) {
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {
'./index.js': ['webpack', 'sourcemap'],
'./index.js': ['webpack'],
'test/unit/!(components)/**/*.vue': ['coverage']
},
webpack: getWebpackConfig(getTestFileName()),

View File

@ -13,7 +13,9 @@ inquirer.prompt([{
name: 'select',
message: '请选择要运行的测试文件:',
choices: files
}], (result) => {
}]).then(result => {
const file = result.select.replace('.spec.js', '');
shell.exec('karma start test/unit/karma.conf.js --color alway --file ' + file);
}).catch(error => {
console.log(error);
});

View File

@ -64,7 +64,7 @@ describe('Area', () => {
}
});
expect(wrapper.vm.areaColumns.length).to.equal(0);
expect(wrapper.vm.columns.length).to.equal(0);
});
it('create an area with columnsNum equal 2', () => {
@ -75,7 +75,7 @@ describe('Area', () => {
}
});
expect(wrapper.vm.areaColumns.length).to.equal(2);
expect(wrapper.vm.columns.length).to.equal(2);
});
it('create an area with columnsNum equal 1', () => {
@ -86,7 +86,7 @@ describe('Area', () => {
}
});
expect(wrapper.vm.areaColumns.length).to.equal(1);
expect(wrapper.vm.columns.length).to.equal(1);
});
it('create an area and click cancel', done => {

1402
yarn.lock

File diff suppressed because it is too large Load Diff