diff --git a/README.md b/README.md index 01b775fb9..5e88cf84d 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ npm i vant@next -S yarn add vant@next ``` +> Tips: Please install Vant 3.0 for Vue 3 projects, see [issue#7035](https://github.com/youzan/vant/issues/7035) + ## Quickstart ```js diff --git a/README.zh-CN.md b/README.zh-CN.md index 4da5c59d7..b979320df 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -48,6 +48,8 @@ npm i vant@next -S yarn add vant@next ``` +> Tips: Vue 3 项目请安装 Vant 3.0,参见 [issue#7035](https://github.com/youzan/vant/issues/7035) + ## 快速上手 ```js diff --git a/docs/markdown/quickstart.en-US.md b/docs/markdown/quickstart.en-US.md index 92c6e1a3b..4b79e1298 100644 --- a/docs/markdown/quickstart.en-US.md +++ b/docs/markdown/quickstart.en-US.md @@ -29,6 +29,8 @@ npm i vant@next -S yarn add vant@next ``` +> Tips: Please install Vant 3.0 for Vue 3 projects, see [issue#7035](https://github.com/youzan/vant/issues/7035) + ## Usage ### 1. Import on demand diff --git a/docs/markdown/quickstart.zh-CN.md b/docs/markdown/quickstart.zh-CN.md index 98ea45d18..443522f10 100644 --- a/docs/markdown/quickstart.zh-CN.md +++ b/docs/markdown/quickstart.zh-CN.md @@ -31,6 +31,8 @@ npm i vant@next -S yarn add vant@next ``` +> Tips: Vue 3 项目请安装 Vant 3.0,参见 [issue#7035](https://github.com/youzan/vant/issues/7035) + ### 示例工程 我们提供了一个基于 Vue Cli 的[示例工程](https://github.com/youzan/vant-demo),示例工程会帮助你了解如下内容: diff --git a/src/calendar/index.js b/src/calendar/index.js index 21468c965..d869fde53 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -272,8 +272,15 @@ export default createComponent({ let height = 0; let currentMonth; + // add offset to avoid rem accuracy issues + // see: https://github.com/youzan/vant/issues/6929 + const viewportOffset = 50; + const viewportTop = top - viewportOffset; + const viewportBottom = bottom + viewportOffset; + for (let i = 0; i < months.length; i++) { - const visible = height <= bottom && height + heights[i] >= top; + const visible = + height <= viewportBottom && height + heights[i] >= viewportTop; if (visible && !currentMonth) { currentMonth = monthRefs[i]; diff --git a/src/toast/index.js b/src/toast/index.js index cbb64932c..35f502dc2 100644 --- a/src/toast/index.js +++ b/src/toast/index.js @@ -39,12 +39,18 @@ function parseOptions(message) { return { message }; } +function isInDocument(element) { + return document.body.contains(element); +} + function createInstance() { /* istanbul ignore if */ if (!inBrowser) { return {}; } + queue = queue.filter((item) => isInDocument(item.$el)); + if (!queue.length || multiple) { const root = document.createElement('div'); document.body.appendChild(root); diff --git a/src/toast/test/index.spec.js b/src/toast/test/index.spec.js index 88da44408..3026877ef 100644 --- a/src/toast/test/index.spec.js +++ b/src/toast/test/index.spec.js @@ -74,26 +74,31 @@ test('icon-prefix prop', async () => { expect(toast.$el.outerHTML).toMatchSnapshot(); }); -test('clear toast', () => { - const toast1 = Toast(); +test('clear toast', async () => { + const toast1 = Toast('1'); + await later(); expect(toast1.value).toBeTruthy(); Toast.clear(); expect(toast1.value).toBeFalsy(); Toast.allowMultiple(); const toast2 = Toast('2'); + await later(); const toast3 = Toast('3'); + await later(); Toast.clear(true); expect(toast2.value).toBeFalsy(); expect(toast3.value).toBeFalsy(); Toast.allowMultiple(false); }); -test('clear multiple toast', () => { +test('clear multiple toast', async () => { Toast.allowMultiple(); Toast.clear(true); const toast1 = Toast.success('1'); + await later(); const toast2 = Toast.success('2'); + await later(); Toast.clear(); expect(toast1.value).toBeFalsy(); expect(toast2.value).toBeTruthy(); diff --git a/src/uploader/index.js b/src/uploader/index.js index e47cb1622..cd3a7dc0d 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -324,7 +324,10 @@ export default createComponent({ const PreviewCover = this.$slots['preview-cover'] && (
- {this.$slots['preview-cover'](item)} + {this.$slots['preview-cover']({ + index, + ...item, + })}
); diff --git a/src/uploader/test/__snapshots__/index.spec.js.snap b/src/uploader/test/__snapshots__/index.spec.js.snap index 172c43fc9..6421e923c 100644 --- a/src/uploader/test/__snapshots__/index.spec.js.snap +++ b/src/uploader/test/__snapshots__/index.spec.js.snap @@ -76,7 +76,7 @@ exports[`preview-cover slot 1`] = `
-
https://img.yzcdn.cn/vant/cat.jpeg
+
url: https://img.yzcdn.cn/vant/cat.jpeg, index: 0
@@ -85,7 +85,7 @@ exports[`preview-cover slot 1`] = `
-
https://img.yzcdn.cn/vant/cat.jpeg
+
url: https://img.yzcdn.cn/vant/cat.jpeg, index: 1
diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 76ab58f30..d9ae2f77d 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -531,7 +531,7 @@ test('preview-cover slot', () => { fileList: [{ url: IMAGE }, { url: IMAGE }], }, scopedSlots: { - 'preview-cover': (item) => item.url, + 'preview-cover': (item) => `url: ${item.url}, index: ${item.index}`, }, }); diff --git a/vant.config.js b/vant.config.js index ab4cdd03e..e37f930e1 100644 --- a/vant.config.js +++ b/vant.config.js @@ -12,7 +12,10 @@ module.exports = { }, site: { defaultLang: 'en-US', - versions: [{ label: '1.x', link: 'https://youzan.github.io/vant/1.x/' }], + versions: [ + { label: '1.x', link: 'https://youzan.github.io/vant/1.x/' }, + { label: '3.x', link: 'https://youzan.github.io/vant/next/' }, + ], baiduAnalytics: { seed: 'ad6b5732c36321f2dafed737ac2da92f', },