diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md
index 7a78d30a6..f5c1f83e9 100644
--- a/docs/markdown/changelog.en-US.md
+++ b/docs/markdown/changelog.en-US.md
@@ -10,6 +10,23 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
- Minor version:released every one to two months, including backwards compatible features.
- Major version:including breaking changes and new features.
+### [v2.10.8](https://github.com/youzan/vant/compare/v2.10.7...v2.10.8)
+
+`2020-09-21`
+
+**Feature**
+
+- SidebarItem: add title slot [#7220](https://github.com/youzan/vant/issues/7220)
+
+**Bug Fixes**
+
+- Calendar: incorrect month title [#7205](https://github.com/youzan/vant/issues/7205)
+- CouponCell: discounted value [#7196](https://github.com/youzan/vant/issues/7196)
+- Field: incorrect disabled color in iOS 14 [#7206](https://github.com/youzan/vant/issues/7206)
+- List: scoped style not applied to first child [#7202](https://github.com/youzan/vant/issues/7202)
+- Swipe: can't disable loop in some cases [#7208](https://github.com/youzan/vant/issues/7208)
+- Swipe: incorrect indicator color trantision [#7207](https://github.com/youzan/vant/issues/7207)
+
### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7)
`2020-09-17`
diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md
index 32a7ea67a..d95cf46f7 100644
--- a/docs/markdown/changelog.zh-CN.md
+++ b/docs/markdown/changelog.zh-CN.md
@@ -10,6 +10,23 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
- 次版本号:每隔一至二个月发布,包含新特性和较大的功能更新,向下兼容。
- 主版本号:发布时间不定,包含不兼容更新,预计下一个主版本会与 Vue 3.0 同期发布。
+### [v2.10.8](https://github.com/youzan/vant/compare/v2.10.7...v2.10.8)
+
+`2020-09-21`
+
+**Feature**
+
+- SidebarItem: 新增 title 插槽 [#7220](https://github.com/youzan/vant/issues/7220)
+
+**Bug Fixes**
+
+- Calendar: 修复月份标题展示错误的问题 [#7205](https://github.com/youzan/vant/issues/7205)
+- CouponCell: 修复金额为 0 时取值逻辑错误的问题 [#7196](https://github.com/youzan/vant/issues/7196)
+- Field: 修复在 iOS 14 上禁用时文字颜色过浅的问题 [#7206](https://github.com/youzan/vant/issues/7206)
+- List: 修复个别情况下第一个子元素的 scoped 样式不生效的问题 [#7202](https://github.com/youzan/vant/issues/7202)
+- Swipe: 修复宽度为小数时无法禁用循环滚动的问题 [#7208](https://github.com/youzan/vant/issues/7208)
+- Swipe: 修复指示器切换时渐变动画闪烁的问题 [#7207](https://github.com/youzan/vant/issues/7207)
+
### [v2.10.7](https://github.com/youzan/vant/compare/v2.10.6...v2.10.7)
`2020-09-17`
diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md
index 59af26ecc..8d6ea215f 100644
--- a/packages/vant-cli/changelog.md
+++ b/packages/vant-cli/changelog.md
@@ -1,5 +1,11 @@
# 更新日志
+### v2.5.4
+
+`2020-09-22`
+
+- 支持在 webpack.config.js 中修改内部 Webpack 配置
+
### v2.5.3
`2020-09-16`
diff --git a/packages/vant-cli/src/common/index.ts b/packages/vant-cli/src/common/index.ts
index 29220cb13..d204361ed 100644
--- a/packages/vant-cli/src/common/index.ts
+++ b/packages/vant-cli/src/common/index.ts
@@ -6,12 +6,14 @@ import {
readFileSync,
outputFileSync,
} from 'fs-extra';
+import merge from 'webpack-merge';
import {
SRC_DIR,
getVantConfig,
ROOT_WEBPACK_CONFIG_FILE,
ROOT_POSTCSS_CONFIG_FILE,
} from './constant';
+import { WebpackConfig } from './types';
export const EXT_REGEXP = /\.\w+$/;
export const SFC_REGEXP = /\.(vue)$/;
@@ -100,21 +102,23 @@ export function normalizePath(path: string): string {
return path.replace(/\\/g, '/');
}
-export function getWebpackConfig(): object {
+export function getWebpackConfig(defaultConfig: WebpackConfig): WebpackConfig {
if (existsSync(ROOT_WEBPACK_CONFIG_FILE)) {
const config = require(ROOT_WEBPACK_CONFIG_FILE);
+ // 如果是函数形式,可能并不仅仅是添加额外的处理流程,而是在原有流程上进行修改
+ // 比如修改markdown-loader,添加options.enableMetaData
if (typeof config === 'function') {
- return config();
+ return config(defaultConfig);
}
- return config;
+ return merge(defaultConfig, config);
}
- return {};
+ return defaultConfig;
}
-export function getPostcssConfig(): object {
+export function getPostcssConfig() {
if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) {
return require(ROOT_POSTCSS_CONFIG_FILE);
}
diff --git a/packages/vant-cli/src/config/webpack.package.ts b/packages/vant-cli/src/config/webpack.package.ts
index 752c034bd..58be3545b 100644
--- a/packages/vant-cli/src/config/webpack.package.ts
+++ b/packages/vant-cli/src/config/webpack.package.ts
@@ -10,9 +10,8 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig {
setBuildTarget('package');
- return merge(
- baseConfig as any,
- {
+ return getWebpackConfig(
+ merge(baseConfig as any, {
mode: 'production',
entry: {
[name]: join(ES_DIR, 'index.js'),
@@ -39,7 +38,6 @@ export function getPackageConfig(isMinify: boolean): WebpackConfig {
optimization: {
minimize: isMinify,
},
- },
- getWebpackConfig()
+ })
);
}
diff --git a/packages/vant-cli/src/config/webpack.site.dev.ts b/packages/vant-cli/src/config/webpack.site.dev.ts
index 805b5c79c..0346e1428 100644
--- a/packages/vant-cli/src/config/webpack.site.dev.ts
+++ b/packages/vant-cli/src/config/webpack.site.dev.ts
@@ -103,5 +103,5 @@ export function getSiteDevBaseConfig(): WebpackConfig {
}
export function getSiteDevConfig(): WebpackConfig {
- return merge(getSiteDevBaseConfig(), getWebpackConfig());
+ return getWebpackConfig(getSiteDevBaseConfig());
}
diff --git a/packages/vant-cli/src/config/webpack.site.prd.ts b/packages/vant-cli/src/config/webpack.site.prd.ts
index 56ddd21a2..cf368e7be 100644
--- a/packages/vant-cli/src/config/webpack.site.prd.ts
+++ b/packages/vant-cli/src/config/webpack.site.prd.ts
@@ -10,9 +10,8 @@ const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
const publicPath = get(vantConfig, 'build.site.publicPath', '/');
export function getSitePrdConfig(): WebpackConfig {
- return merge(
- getSiteDevBaseConfig(),
- {
+ return getWebpackConfig(
+ merge(getSiteDevBaseConfig(), {
mode: 'production',
stats: 'none',
performance: {
@@ -25,7 +24,6 @@ export function getSitePrdConfig(): WebpackConfig {
filename: '[name].[hash:8].js',
chunkFilename: 'async_[name].[chunkhash:8].js',
},
- },
- getWebpackConfig()
+ })
);
}
diff --git a/src/pagination/README.md b/src/pagination/README.md
index 60ed3c1a5..1b20ed4a4 100644
--- a/src/pagination/README.md
+++ b/src/pagination/README.md
@@ -45,6 +45,20 @@ export default {
/>
```
+### Custom Render
+
+```html
+
+
+
+
+
+
+
+ {{ text }}
+
+```
+
## API
### Props
@@ -66,3 +80,11 @@ export default {
| Event | Description | Arguments |
| ------ | ------------------------ | --------- |
| change | Triggered on page change | - |
+
+### Slots
+
+| Name | Description | Default |
+| --- | --- | --- |
+| prev-text | custom prev slot | `-` |
+| next-text | custom next slot | `-` |
+| page | pagination item slot | `{ number: number, text: string, active: boolean }` |
diff --git a/src/pagination/README.zh-CN.md b/src/pagination/README.zh-CN.md
index 509856f13..ebca0a1c3 100644
--- a/src/pagination/README.zh-CN.md
+++ b/src/pagination/README.zh-CN.md
@@ -45,6 +45,20 @@ export default {
/>
```
+### 自定义渲染
+
+```html
+
+
+
+
+
+
+
+ {{ text }}
+
+```
+
## API
### Props
@@ -66,3 +80,11 @@ export default {
| 事件名 | 说明 | 回调参数 |
| ------ | -------------- | -------- |
| change | 页码改变时触发 | - |
+
+### Slots
+
+| 名称 | 描述 | 默认值 |
+| --- | --- | --- |
+| prev-text | 自定义上一页插槽 | `-` |
+| next-text | 自定义下一页插槽 | `-` |
+| page | 自定义页码插槽 | `{ number: number, text: string, active: boolean }` |
diff --git a/src/pagination/demo/index.vue b/src/pagination/demo/index.vue
index d579d6819..37a977ed1 100644
--- a/src/pagination/demo/index.vue
+++ b/src/pagination/demo/index.vue
@@ -31,6 +31,22 @@
:next-text="t('nextText')"
/>
+
+
+
+
+
+
+
+
+
+ {{ text }}
+
+
@@ -40,12 +56,14 @@ export default {
'zh-CN': {
title2: '简单模式',
title3: '显示省略号',
+ title4: '自定义渲染',
prevText: '上一页',
nextText: '下一页',
},
'en-US': {
title2: 'Simple Mode',
title3: 'Show ellipses',
+ title4: 'Custom Render',
prevText: 'Prev',
nextText: 'Next',
},
@@ -56,6 +74,7 @@ export default {
currentPage1: 1,
currentPage2: 1,
currentPage3: 1,
+ currentPage4: 1,
};
},
};
diff --git a/src/pagination/index.js b/src/pagination/index.js
index b8f13ce39..f1d8b281a 100644
--- a/src/pagination/index.js
+++ b/src/pagination/index.js
@@ -142,7 +142,9 @@ export default createComponent({
]}
onClick={onSelect(value - 1)}
>
- {props.prevText || t('prev')}
+ {slots['prev-text']
+ ? slots['prev-text']()
+ : props.prevText || t('prev')}
{pages.value.map((page) => (
- {page.text}
+ {slots.page ? slots.page(page) : page.text}
))}
{renderDesc()}
@@ -165,7 +167,9 @@ export default createComponent({
]}
onClick={onSelect(value + 1)}
>
- {props.nextText || t('next')}
+ {slots['next-text']
+ ? slots['next-text']()
+ : props.nextText || t('next')}
);
diff --git a/src/pagination/test/__snapshots__/demo.spec.js.snap b/src/pagination/test/__snapshots__/demo.spec.js.snap
index c4e54ef49..4b4c78a6a 100644
--- a/src/pagination/test/__snapshots__/demo.spec.js.snap
+++ b/src/pagination/test/__snapshots__/demo.spec.js.snap
@@ -30,5 +30,18 @@ exports[`renders demo correctly 1`] = `
+
+
+
`;
diff --git a/src/pagination/test/__snapshots__/index.spec.js.snap b/src/pagination/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..440c7e3d6
--- /dev/null
+++ b/src/pagination/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,25 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render page slot 1`] = `
+
+`;
+
+exports[`render prev-text & next-text slot 1`] = `
+
+`;
diff --git a/src/pagination/test/index.spec.js b/src/pagination/test/index.spec.js
new file mode 100644
index 000000000..e4915ac20
--- /dev/null
+++ b/src/pagination/test/index.spec.js
@@ -0,0 +1,31 @@
+import { mount } from '../../../test';
+import Paginaion from '..';
+
+test('render prev-text & next-text slot', () => {
+ const wrapper = mount(Paginaion, {
+ propsData: {
+ totalItems: 50,
+ showPageSize: 5,
+ },
+ scopedSlots: {
+ 'prev-text': () => 'Custom PrevText',
+ 'next-text': () => 'Custom NextText',
+ },
+ });
+
+ expect(wrapper).toMatchSnapshot();
+});
+
+test('render page slot', () => {
+ const wrapper = mount(Paginaion, {
+ propsData: {
+ totalItems: 50,
+ showPageSize: 5,
+ },
+ scopedSlots: {
+ page: ({ text }) => `${text}`,
+ },
+ });
+
+ expect(wrapper).toMatchSnapshot();
+});
diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js
index 6109de0b0..fa3abfad5 100644
--- a/src/sidebar-item/index.js
+++ b/src/sidebar-item/index.js
@@ -17,7 +17,7 @@ export default createComponent({
emits: ['click'],
- setup(props, { emit }) {
+ setup(props, { emit, slots }) {
const route = useRoute();
const { parent, index } = useParent(SIDEBAR_KEY);
@@ -39,7 +39,7 @@ export default createComponent({
return (
- {title}
+ {slots.title ? slots.title() : title}
diff --git a/src/sidebar/README.md b/src/sidebar/README.md
index 3eb2e49f3..a06360219 100644
--- a/src/sidebar/README.md
+++ b/src/sidebar/README.md
@@ -111,3 +111,9 @@ export default {
| Event | Description | Arguments |
| ----- | ------------------------- | ---------------------------- |
| click | Triggered when click item | index: index of current item |
+
+### SidebarItem Slots
+
+| Name | Description |
+| --------------- | ----------------- |
+| title `v2.10.8` | Custom item title |
diff --git a/src/sidebar/README.zh-CN.md b/src/sidebar/README.zh-CN.md
index 76f07347e..e7fac9863 100644
--- a/src/sidebar/README.zh-CN.md
+++ b/src/sidebar/README.zh-CN.md
@@ -15,7 +15,7 @@ app.use(SidebarItem);
### 基础用法
-通过`v-model`绑定当前选中项的索引
+通过 `v-model` 绑定当前选中项的索引。
```html
@@ -37,7 +37,7 @@ export default {
### 徽标提示
-设置`dot`属性后,会在右上角展示一个小红点。设置`badge`属性后,会在右上角展示相应的徽标
+设置 `dot` 属性后,会在右上角展示一个小红点;设置 `badge` 属性后,会在右上角展示相应的徽标。
```html
@@ -49,7 +49,7 @@ export default {
### 禁用选项
-通过`disabled`属性禁用选项
+通过 `disabled` 属性禁用选项。
```html
@@ -61,7 +61,7 @@ export default {
### 监听切换事件
-设置`change`方法来监听切换导航项时的事件
+设置 `change` 方法来监听切换导航项时的事件。
```html
@@ -119,3 +119,9 @@ export default {
| 事件名 | 说明 | 回调参数 |
| ------ | ---------- | ----------------------- |
| click | 点击时触发 | index: 当前导航项的索引 |
+
+### SidebarItem Slots
+
+| Name | Description |
+| --------------- | ----------- |
+| title `v2.10.8` | 自定义标题 |
diff --git a/src/sidebar/test/__snapshots__/index.spec.js.snap b/src/sidebar/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..d31a8a85e
--- /dev/null
+++ b/src/sidebar/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`title slot 1`] = `
+
+`;
diff --git a/src/sidebar/test/index.spec.js b/src/sidebar/test/index.spec.js
index a3e533410..966eb72d0 100644
--- a/src/sidebar/test/index.spec.js
+++ b/src/sidebar/test/index.spec.js
@@ -76,3 +76,22 @@ test('without parent', () => {
expect(err).toBeTruthy();
}
});
+
+test('title slot', () => {
+ const wrapper = mount({
+ template: `
+
+
+ Title Slot
+
+
+ `,
+ data() {
+ return {
+ active: 0,
+ };
+ },
+ });
+
+ expect(wrapper).toMatchSnapshot();
+});
diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md
index 68050a0fe..699e21985 100644
--- a/src/tab/README.zh-CN.md
+++ b/src/tab/README.zh-CN.md
@@ -289,7 +289,7 @@ export default {
### Tab Slots
-| 名称 | 说明 |
-| ------- | -------------------------- |
-| default | 标签页内容 |
-| title | 自定义标题,不支持动态渲染 |
+| 名称 | 说明 |
+| ------- | ---------- |
+| default | 标签页内容 |
+| title | 自定义标题 |