Compare commits

...

51 Commits

Author SHA1 Message Date
chenjiahan
bc468d7219 release: 3.6.12 2023-07-20 20:52:00 +08:00
跃跃
1e585b5ce0
fix(Uploader): render objectUrl to avoid perf issue (#12106) 2023-07-20 20:50:03 +08:00
Gavin
f56634c4a5
docs(DatetimePicker): fix docs code (#11750) 2023-04-13 17:39:25 +08:00
chenxueli
c88f457e84
feat(Uploader): support avif image format (#11655) 2023-03-09 09:31:56 +08:00
neverland
e6fd665707
docs(changelog): vant@3.6.11 (#11417) 2022-12-25 20:39:51 +08:00
chenjiahan
dbf3fe5f8b release: 3.6.11 2022-12-25 20:37:33 +08:00
wnx
5a1188c468
fix(Field): incorrect cursor position when value length exceeds maxlength or when formatter is used (#11360) 2022-12-18 10:29:30 +08:00
neverland
7abb6bd6f9
docs(changelog): 3.6.10 (#11352) 2022-12-03 20:27:33 +08:00
chenjiahan
9e53bd5f89 release: 3.6.10 2022-12-03 20:26:05 +08:00
neverland
b27a3cedfe fix(Field): incorrect cursor position when using formatter (#11348) 2022-12-02 19:18:18 +08:00
neverland
74d77a6c12
docs(changelog): vant@3.6.9 (#11340) 2022-12-01 17:53:14 +08:00
chenjiahan
e172db192a release: 3.6.9 2022-12-01 17:51:24 +08:00
Mikasa33
26b442b517 docs(Dialog): fix the min version of footer slot (#11336) 2022-12-01 12:47:44 +08:00
neverland
32b5d39f7b fix(Field): set selection range only when focused (#11333) 2022-11-30 21:37:31 +08:00
Gavin
882ca4db4e
docs: fix Chinese change log (#11320) 2022-11-27 22:37:02 +08:00
neverland
af2d52f359 docs: add maintenance status table (#11315) 2022-11-26 22:51:11 +08:00
chenjiahan
c8270a1059 docs: fix publicPath 2022-11-26 22:15:38 +08:00
chenjiahan
b4339fd6f0 chore: adjust site target-folder 2022-11-26 22:13:37 +08:00
neverland
3012e7c705
docs(changelog): vant@3.6.8 (#11314) 2022-11-26 22:11:42 +08:00
chenjiahan
e9203517ee release: 3.6.8 2022-11-26 22:09:47 +08:00
chenjiahan
73469bf240 chore: fix release npm tag 2022-11-26 22:08:29 +08:00
chenjiahan
4713238b00 release: 3.6.7 2022-11-26 22:05:48 +08:00
neverland
11cc1a4932
chore: switch vant@3 npm tag to latest-v3 (#11313)
* chore: switch vant@3 npm tag to latest-v3

* chore: adjust deploy site
2022-11-26 22:04:46 +08:00
neverland
521748a5f8 fix(Field): keep selection position after updating value (#11308) 2022-11-26 20:18:16 +08:00
neverland
41cf5706fd
docs(changelog): vant@3.6.6 (#11283) 2022-11-23 09:35:11 +08:00
chenjiahan
1f3711236d release: 3.6.6 2022-11-23 09:32:38 +08:00
Tsdy
e18a3d49ce
fix(Cell): arrow-direction assignment right is invalid (#11279) 2022-11-21 10:22:20 +08:00
neverland
772875535f fix(NumberKeyboard): should inherit attrs when using teleport (#11274) 2022-11-19 18:52:36 +08:00
neverland
ccc0649cba fix(List): incorrect initial loading value (#11275) 2022-11-19 18:52:26 +08:00
neverland
44281be985
docs(changelog): vant@3.6.5 (#11232) 2022-11-08 10:46:58 +08:00
chenjiahan
78d6bcc939 release: 3.6.5 2022-11-08 10:43:14 +08:00
若川
711f9cc852
fix(lazyload): lazy-image h is not a function (#11230)
in vue 3.x h is not function. this.$slots.default is  a function.

[vue 3.x refs render-function-api-change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md) 
[vue 3.x docs h](https://cn.vuejs.org/api/render-function.html#h)

- reappear
- test

```vue
// vant/packages/vant/src/lazyload/demo/index.vue
<script lang="ts">
import Lazyload from '..';

if (window.app) {
  window.app.use(Lazyload, { lazyComponent: true, lazyImage: true });
}
</script>
<template>
   <demo-block :title="t('basicUsage')">
    <lazy-image v-for="img in imageList" :key="img" :src="img">
    </lazy-image>
  </demo-block>
</teamplate>
```
2022-11-08 10:14:49 +08:00
neverland
97d2badd45
docs(ImagePreview): improve document (#11137) 2022-10-15 22:58:45 +08:00
uniquker
7d48159e65
feat(ImagePreview): add preview image slot (#11133) 2022-10-15 20:51:49 +08:00
neverland
685351799e docs(TreeSelect): make document consistent with demo (#11136) 2022-10-15 20:50:26 +08:00
neverland
f595d41b3b
docs(changelog): @vant/cli v3.6.4 (#11124) 2022-10-07 23:30:54 +08:00
chenjiahan
c20a51c07d release: 3.6.4 2022-10-07 23:26:39 +08:00
neverland
d88c04cae4 fix(Tabs): incorrect nav scroll animation in some cases (#11116)
* fix(Tabs): incorrect nav scroll animation in some cases

* chore: fix snapshot
2022-10-06 16:23:46 +08:00
neverland
8f12b6c715 fix(Tabs): scroll position when using nav-bottom slot (#11115) 2022-10-06 16:07:34 +08:00
neverland
46c1ce3ae3 docs: add faq of uni-app (#11114) 2022-10-05 09:28:55 +08:00
neverland
a0d07a373b perf(cli): code split documents (#11111) 2022-10-04 08:55:58 +08:00
neverland
a2d1280044
docs: fix website redirect (#11097) 2022-09-28 21:54:15 +08:00
neverland
c6baa88461
docs(changelog): vant@3.6.3 (#11086) 2022-09-24 23:05:54 +08:00
chenjiahan
808ae4a076 release: 3.6.3 2022-09-24 23:02:18 +08:00
neverland
8444c6f2f0
fix(Tabs): incorrect scroll position in some cases (#11085) 2022-09-24 22:59:47 +08:00
chenjiahan
3d41ac66a1 chore: update deploy v3 site 2022-09-24 20:37:22 +08:00
neverland
41cfae4aa6
fix(Tabs): incorrect scroll position when inited (#11059) 2022-09-18 22:06:37 +08:00
chenjiahan
2d47824ae7 docs: update links for 3.x branch 2022-09-12 11:42:33 +08:00
neverland
abad89d7dd docs: update links (#11041) 2022-09-12 11:27:37 +08:00
chenjiahan
1294e51248 chore: update branches in GitHub actions 2022-09-10 22:00:18 +08:00
chenjiahan
99833f2185 docs: switch dev branch to v4 2022-09-10 21:53:14 +08:00
61 changed files with 856 additions and 387 deletions

View File

@ -1,6 +1,6 @@
### Before submitting a pull request, please make sure the following is done: ### Before submitting a pull request, please make sure the following is done:
1. Read the [contributing guide](https://github.com/vant-ui/vant/blob/dev/.github/CONTRIBUTING.md). 1. Read the [contributing guide](https://github.com/vant-ui/vant/blob/3.x/.github/CONTRIBUTING.md).
2. If you've added code that should be tested, add tests. 2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation. 3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes (`npm test`). 4. Ensure the test suite passes (`npm test`).

View File

@ -2,7 +2,7 @@ name: Deploy V3 Site
on: on:
push: push:
branches: [dev] branches: [3.x]
paths: paths:
- 'packages/vant/docs/**' - 'packages/vant/docs/**'
@ -15,7 +15,7 @@ jobs:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: 'dev' ref: '3.x'
- name: Install pnpm - name: Install pnpm
run: npm i pnpm@7 -g run: npm i pnpm@7 -g
@ -32,8 +32,17 @@ jobs:
run: npm run build:site run: npm run build:site
- name: Deploy 🚀 - name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.1 uses: JamesIves/github-pages-deploy-action@v4.4.0
with: with:
branch: gh-pages branch: gh-pages
folder: packages/vant/site-dist folder: packages/vant/site-dist
clean: false target-folder: v3
- name: Deploy for GitHub 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.0
with:
branch: main
folder: packages/vant/site-dist
token: ${{ secrets.VANT_UI_TOKEN }}
repository-name: vant-ui/vant-ui.github.io
target-folder: vant/v3

View File

@ -2,7 +2,7 @@ name: Sync to Gitee
on: on:
push: push:
branches: [dev, 2.x, gh-pages] branches: [dev, 2.x, 3.x, gh-pages]
workflow_dispatch: workflow_dispatch:

View File

@ -37,7 +37,7 @@
- 🍭 Support Tree Shaking - 🍭 Support Tree Shaking
- 🍭 Support Custom Theme - 🍭 Support Custom Theme
- 🍭 Support Accessibility (still improving) - 🍭 Support Accessibility (still improving)
- 🍭 Support Dark Mode (Requires upgrade to [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/en-US/config-provider)) - 🍭 Support Dark Mode
- 🍭 Support SSR - 🍭 Support SSR
- 🌍 Support i18n, built-in 20+ languages - 🌍 Support i18n, built-in 20+ languages
@ -92,16 +92,15 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
| --- | --- | | --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI | | [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos | | [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-cli](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli) | Scaffold for UI library |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-icons](https://github.com/vant-ui/vant/tree/3.x/packages/vant-icons) | Vant icons |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | | [vant-touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator) | Using vant in desktop browsers |
## Community Ecosystem ## Community Ecosystem
| Project | Description | | Project | Description |
| --- | --- | | --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant | | [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | React mobile UI Components based on Vant |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI | | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro | | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI | | [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
@ -112,7 +111,7 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
- [Documentation](https://vant-ui.github.io/vant) - [Documentation](https://vant-ui.github.io/vant)
- [Changelog](https://vant-ui.github.io/vant#/en-US/changelog) - [Changelog](https://vant-ui.github.io/vant#/en-US/changelog)
- [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) - [Discussions](https://github.com/vant-ui/vant/discussions)
## Preview ## Preview

View File

@ -41,7 +41,7 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
- 🍭 支持主题定制,内置 700+ 个主题变量 - 🍭 支持主题定制,内置 700+ 个主题变量
- 🍭 支持按需引入和 Tree Shaking - 🍭 支持按需引入和 Tree Shaking
- 🍭 支持无障碍访问(持续改进中) - 🍭 支持无障碍访问(持续改进中)
- 🍭 支持深色模式(从 [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/zh-CN/config-provider) 开始支持) - 🍭 支持深色模式
- 🍭 支持服务器端渲染 - 🍭 支持服务器端渲染
- 🌍 支持国际化,内置 20+ 种语言包 - 🌍 支持国际化,内置 20+ 种语言包
@ -98,9 +98,9 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| --- | --- | | --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 | | [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 | | [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-cli](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli) | 开箱即用的组件库搭建工具 |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-icons](https://github.com/vant-ui/vant/tree/3.x/packages/vant-icons) | Vant 图标库 |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | | [vant-touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
## 社区生态 ## 社区生态
@ -109,7 +109,6 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| 项目 | 描述 | | 项目 | 描述 |
| --- | --- | | --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 框架移动端组件库 | | [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 框架移动端组件库 |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | 参照 Vant 打造的 React 框架移动端组件库 |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 | | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 | | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 | | [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
@ -120,7 +119,8 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
- [详细文档](https://vant-contrib.gitee.io/vant) - [详细文档](https://vant-contrib.gitee.io/vant)
- [更新日志](https://vant-contrib.gitee.io/vant#/zh-CN/changelog) - [更新日志](https://vant-contrib.gitee.io/vant#/zh-CN/changelog)
- [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) - [码云镜像仓库](https://gitee.com/vant-contrib/vant)
- [Discussions 讨论区](https://github.com/vant-ui/vant/discussions)
## 手机预览 ## 手机预览

View File

@ -65,7 +65,7 @@ Please add the followed config to `package.json` file.
## More Details ## More Details
- [cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.md) - [cli](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/commands.md)
- [config](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.md) - [config](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/config.md)
- [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md) - [directory structure](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/directory.md)
- [CHANGELOG](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md) - [CHANGELOG](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/changelog.md)

View File

@ -62,7 +62,7 @@ pnpm add @vant/cli -D
## 详细文档 ## 详细文档
- [命令](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.zh-CN.md) - [命令](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/commands.zh-CN.md)
- [配置指南](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.zh-CN.md) - [配置指南](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/config.zh-CN.md)
- [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md) - [目录结构](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/directory.zh-CN.md)
- [更新日志](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md) - [更新日志](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/changelog.md)

View File

@ -29,7 +29,7 @@ Start local dev server for browsering components and demo.
Build Vue component library. Build Vue component library.
Files will be output to `es` and `lib` directory. More details [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md) Files will be output to `es` and `lib` directory. More details [directory structure](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/directory.md)
Please add the followed config to `package.json` when publish to npm. Please add the followed config to `package.json` when publish to npm.

View File

@ -31,7 +31,7 @@ npx vant-cli dev
构建组件库。 构建组件库。
运行 build 命令会在 `es``lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md)。 运行 build 命令会在 `es``lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli/docs/directory.zh-CN.md)。
发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别: 发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别:

View File

@ -1,12 +1,7 @@
import glob from 'fast-glob'; import glob from 'fast-glob';
import { join, parse } from 'path'; import { join, parse } from 'path';
import { existsSync, readFileSync, readdirSync } from 'fs'; import { existsSync, readFileSync, readdirSync } from 'fs';
import { import { pascalize, getVantConfig, normalizePath } from '../common/index.js';
isDev,
pascalize,
getVantConfig,
normalizePath,
} from '../common/index.js';
import { import {
SRC_DIR, SRC_DIR,
DOCS_DIR, DOCS_DIR,
@ -80,10 +75,7 @@ function genImportDocuments(items: DocumentItem[]) {
return items return items
.map((item) => { .map((item) => {
const path = normalizePath(item.path); const path = normalizePath(item.path);
if (isDev()) {
return `const ${item.name} = () => import('${path}');`; return `const ${item.name} = () => import('${path}');`;
}
return `import ${item.name} from '${path}';`;
}) })
.join('\n'); .join('\n');
} }

View File

@ -132,7 +132,7 @@ module.exports = {
### Adapt to PC Browsers ### Adapt to PC Browsers
Vant is a mobile-first component library, if you want to use Vant in PC browsers, you can use the [@vant/touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) module. This module will automatically convert the mouse events of the PC browser into the touch events of the mobile browser. Vant is a mobile-first component library, if you want to use Vant in PC browsers, you can use the [@vant/touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator) module. This module will automatically convert the mouse events of the PC browser into the touch events of the mobile browser.
```bash ```bash
# Install # Install

View File

@ -197,7 +197,7 @@ module.exports = {
Vant 是一个面向移动端的组件库,因此默认只适配了移动端设备,这意味着组件只监听了移动端的 `touch` 事件,没有监听桌面端的 `mouse` 事件。 Vant 是一个面向移动端的组件库,因此默认只适配了移动端设备,这意味着组件只监听了移动端的 `touch` 事件,没有监听桌面端的 `mouse` 事件。
如果你需要在桌面端使用 Vant可以引入我们提供的 [@vant/touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator),这个库会在桌面端自动将 `mouse` 事件转换成对应的 `touch` 事件,使得组件能够在桌面端使用。 如果你需要在桌面端使用 Vant可以引入我们提供的 [@vant/touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator),这个库会在桌面端自动将 `mouse` 事件转换成对应的 `touch` 事件,使得组件能够在桌面端使用。
```bash ```bash
# 安装模块 # 安装模块

View File

@ -19,6 +19,90 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
## Details ## Details
### [v3.6.11](https://github.com/vant-ui/vant/compare/v3.6.10...v3.6.11)
`2022-12-25`
**Bug Fixes**
- Field: incorrect cursor position when value length exceeds maxlength or when formatter is used [#11360](https://github.com/vant-ui/vant/issues/11360)
### [v3.6.10](https://github.com/vant-ui/vant/compare/v3.6.9...v3.6.10)
`2022-12-03`
**Bug Fixes**
- Field: incorrect cursor position when using formatter [#11348](https://github.com/vant-ui/vant/issues/11348)
### [v3.6.9](https://github.com/vant-ui/vant/compare/v3.6.8...v3.6.9)
`2022-12-01`
**Bug Fixes**
- Field: set selection range only when focused [#11333](https://github.com/vant-ui/vant/issues/11333)
### [v3.6.8](https://github.com/vant-ui/vant/compare/v3.6.7...v3.6.8)
`2022-11-26`
- Switch npm tag of vant@3 to `latest-v3`
### [v3.6.7](https://github.com/vant-ui/vant/compare/v3.6.6...v3.6.7)
`2022-11-26`
**Bug Fixes**
- Field: keep selection position after updating value [#11308](https://github.com/vant-ui/vant/issues/11308)
### [v3.6.6](https://github.com/vant-ui/vant/compare/v3.6.5...v3.6.6)
`2022-11-23`
**Bug Fixes**
- Cell: arrow-direction assignment right is invalid [#11279](https://github.com/vant-ui/vant/issues/11279)
- List: incorrect initial loading value [#11275](https://github.com/vant-ui/vant/issues/11275)
- NumberKeyboard: should inherit attrs when using teleport [#11274](https://github.com/vant-ui/vant/issues/11274)
### [v3.6.5](https://github.com/vant-ui/vant/compare/v3.6.4...v3.6.5)
`2022-11-08`
**Feature**
- ImagePreview: add preview image slot [#11133](https://github.com/vant-ui/vant/issues/11133)
**Bug Fixes**
- lazyload: lazy-image h is not a function [#11230](https://github.com/vant-ui/vant/issues/11230)
### [v3.6.4](https://github.com/vant-ui/vant/compare/v3.6.3...v3.6.4)
`2022-10-07`
**Bug Fixes**
- Tabs: incorrect nav scroll animation in some cases [#11116](https://github.com/vant-ui/vant/issues/11116)
- Tabs: scroll position when using nav-bottom slot [#11115](https://github.com/vant-ui/vant/issues/11115)
### [v3.6.3](https://github.com/vant-ui/vant/compare/v3.6.2...v3.6.3)
`2022-09-24`
**Feature**
- Dialog: message-align can be justify [#11014](https://github.com/vant-ui/vant/issues/11014)
- Image: add block prop [#11022](https://github.com/vant-ui/vant/issues/11022)
**Bug Fixes**
- Tabs: incorrect scroll position in some cases [#11085](https://github.com/vant-ui/vant/issues/11085)
- Tabs: incorrect scroll position when inited [#11059](https://github.com/vant-ui/vant/issues/11059)
- utils: avoid getting unexpected value [#11010](https://github.com/vant-ui/vant/issues/11010)
### [v3.6.2](https://github.com/vant-ui/vant/compare/v3.6.1...v3.6.2) ### [v3.6.2](https://github.com/vant-ui/vant/compare/v3.6.1...v3.6.2)
`2022-09-04` `2022-09-04`

View File

@ -19,6 +19,90 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
## 更新内容 ## 更新内容
### [v3.6.11](https://github.com/vant-ui/vant/compare/v3.6.10...v3.6.11)
`2022-12-25`
**Bug Fixes**
- Field: 修复使用 formatter 时光标位置可能错误的问题 [#11360](https://github.com/vant-ui/vant/issues/11360)
### [v3.6.10](https://github.com/vant-ui/vant/compare/v3.6.9...v3.6.10)
`2022-12-03`
**Bug Fixes**
- Field: 修复使用 formatter 时光标位置错误的问题 [#11348](https://github.com/vant-ui/vant/issues/11348)
### [v3.6.9](https://github.com/vant-ui/vant/compare/v3.6.8...v3.6.9)
`2022-12-01`
**Bug Fixes**
- Field: 修复未选中时修改绑定的值会导致键盘弹出的问题 [#11333](https://github.com/vant-ui/vant/issues/11333)
### [v3.6.8](https://github.com/vant-ui/vant/compare/v3.6.7...v3.6.8)
`2022-11-26`
- 将 vant@3 的 npm tag 切换至 `latest-v3`
### [v3.6.7](https://github.com/vant-ui/vant/compare/v3.6.6...v3.6.7)
`2022-11-26`
**Bug Fixes**
- Field: 修复格式化值后,光标位置错误的问题 [#11308](https://github.com/vant-ui/vant/issues/11308)
### [v3.6.6](https://github.com/vant-ui/vant/compare/v3.6.5...v3.6.6)
`2022-11-23`
**Bug Fixes**
- Cell: 修复 arrow-direction 属性设置为 right 不生效的问题 [#11279](https://github.com/vant-ui/vant/issues/11279)
- List: 修复初始的 loading 状态可能不正确的问题 [#11275](https://github.com/vant-ui/vant/issues/11275)
- NumberKeyboard: 修复使用 teleport 属性时未正确继承 attrs 的问题 [#11274](https://github.com/vant-ui/vant/issues/11274)
### [v3.6.5](https://github.com/vant-ui/vant/compare/v3.6.4...v3.6.5)
`2022-11-08`
**Feature**
- ImagePreview: 新增 preview image 插槽 [#11133](https://github.com/vant-ui/vant/issues/11133)
**Bug Fixes**
- lazyload: 修复使用 lazy-image 时提示 h is not a function 的问题 [#11230](https://github.com/vant-ui/vant/issues/11230)
### [v3.6.4](https://github.com/vant-ui/vant/compare/v3.6.3...v3.6.4)
`2022-10-07`
**Bug Fixes**
- Tabs: 修复开启 scrollspy 时个别情况下标题栏滚动位置错误的问题 [#11116](https://github.com/vant-ui/vant/issues/11116)
- Tabs: 修复开启 scrollspy 时 nav-bottom 插槽遮挡内容的问题 [#11115](https://github.com/vant-ui/vant/issues/11115)
### [v3.6.3](https://github.com/vant-ui/vant/compare/v3.6.2...v3.6.3)
`2022-09-24`
**Feature**
- Dialog: message-align 属性支持设置为 justify [#11014](https://github.com/vant-ui/vant/issues/11014)
- Image: 新增 block 属性 [#11022](https://github.com/vant-ui/vant/issues/11022)
**Bug Fixes**
- Tabs: 修复个别情况下页面滚动位置错误的问题 [#11085](https://github.com/vant-ui/vant/issues/11085)
- Tabs: 修复初始化时菜单横向滚动位置错误的问题 [#11059](https://github.com/vant-ui/vant/issues/11059)
- Locale: 修复读取 i18n 文案时可能获取到 JS 原生方法的问题 [#11010](https://github.com/vant-ui/vant/issues/11010)
### [v3.6.2](https://github.com/vant-ui/vant/compare/v3.6.1...v3.6.2) ### [v3.6.2](https://github.com/vant-ui/vant/compare/v3.6.1...v3.6.2)
`2022-09-04` `2022-09-04`

View File

@ -38,9 +38,9 @@ pnpm dev
仓库的不同分支对应不同的 Vant 版本,请切换到对应分支进行开发: 仓库的不同分支对应不同的 Vant 版本,请切换到对应分支进行开发:
- dev 分支对应 Vant 4 版本,适用于 Vue 3
- 3.x 分支对应 Vant 3 版本 ,适用于 Vue 3
- 2.x 分支对应 Vant 2 版本,适用于 Vue 2 - 2.x 分支对应 Vant 2 版本,适用于 Vue 2
- dev 分支对应 Vant 3 版本 ,适用于 Vue 3
- next 分支对应 Vant 4 版本,适用于 Vue 3
### 镜像仓库 ### 镜像仓库

View File

@ -22,7 +22,7 @@ Contains color specifications, font specifications, and component design specifi
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/tab_202009101415.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)"> <img src="https://fastly.jsdelivr.net/npm/@vant/assets/tab_202009101415.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)">
<a class="design-download" href="https://github.com/vant-ui/vant/blob/dev/packages/vant/docs/assets/design.sketch?raw=true">Download</a> <a class="design-download" href="https://github.com/vant-ui/vant/blob/3.x/packages/vant/docs/assets/design.sketch?raw=true">Download</a>
### Icons (Sketch) ### Icons (Sketch)
@ -30,7 +30,7 @@ Contains icon library resources.
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/design-icons-0321.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)"> <img src="https://fastly.jsdelivr.net/npm/@vant/assets/design-icons-0321.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)">
<a class="design-download" href="https://github.com/vant-ui/vant/blob/dev/packages/vant-icons/assets/icons.sketch?raw=true">Download</a> <a class="design-download" href="https://github.com/vant-ui/vant/blob/3.x/packages/vant-icons/assets/icons.sketch?raw=true">Download</a>
### Axure ### Axure

View File

@ -22,7 +22,7 @@
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/tab_202009101415.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)"> <img src="https://fastly.jsdelivr.net/npm/@vant/assets/tab_202009101415.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)">
<a class="design-download" href="https://github.com/vant-ui/vant/blob/dev/packages/vant/docs/assets/design.sketch?raw=true">下载</a> <a class="design-download" href="https://github.com/vant-ui/vant/blob/3.x/packages/vant/docs/assets/design.sketch?raw=true">下载</a>
### 图标设计稿Sketch ### 图标设计稿Sketch
@ -30,7 +30,7 @@
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/design-icons-0321.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)"> <img src="https://fastly.jsdelivr.net/npm/@vant/assets/design-icons-0321.png" style="width: 80%; box-shadow: 0 1px 2px rgba(0,0,0,.2)">
<a class="design-download" href="https://github.com/vant-ui/vant/blob/dev/packages/vant-icons/assets/icons.sketch?raw=true">下载</a> <a class="design-download" href="https://github.com/vant-ui/vant/blob/3.x/packages/vant-icons/assets/icons.sketch?raw=true">下载</a>
#### 在线资源 #### 在线资源

View File

@ -68,6 +68,12 @@ Select 是桌面端常用的组件,但它的交互形式不适合移动端。
在移动端,我们推荐使用 [Picker 选择器组件](#/zh-CN/picker) 作为代替。 在移动端,我们推荐使用 [Picker 选择器组件](#/zh-CN/picker) 作为代替。
### 是否支持在 uni-app 中使用?
Vant 所有组件都是基于 Vue 框架实现的,没有针对 uni-app 进行适配,因此不保证各个组件在 uni-app 下的可用性。
如果你在 uni-app 中使用 Vant 遇到问题,建议向 uni-app 进行反馈。
### 部分组件无法在桌面端进行操作? ### 部分组件无法在桌面端进行操作?
参见[桌面端适配](#/zh-CN/advanced-usage#zhuo-mian-duan-gua-pei)。 参见[桌面端适配](#/zh-CN/advanced-usage#zhuo-mian-duan-gua-pei)。

View File

@ -19,7 +19,7 @@
- 🍭 Support Tree Shaking - 🍭 Support Tree Shaking
- 🍭 Support Custom Theme - 🍭 Support Custom Theme
- 🍭 Support Accessibility (still improving) - 🍭 Support Accessibility (still improving)
- 🍭 Support Dark Mode (Requires upgrade to [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/en-US/config-provider)) - 🍭 Support Dark Mode
- 🍭 Support SSR - 🍭 Support SSR
- 🌍 Support i18n, built-in 20+ languages - 🌍 Support i18n, built-in 20+ languages
@ -33,6 +33,17 @@ Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3). Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
### Maintenance Status
The current maintenance status of each version of Vant is as follows:
| Name | Framework | Release | Latest Version | Status |
| --- | --- | --- | --- | --- |
| Vant 4 | Vue 3 | `2022.11` | ![](https://img.shields.io/npm/v/vant/latest?style=flat-square) | Under active development |
| Vant 3 | Vue 3 | `2020.12` | ![](https://img.shields.io/npm/v/vant/latest-v3?style=flat-square) | Bugfix only |
| Vant 2 | Vue 2 | `2019.06` | ![](https://img.shields.io/npm/v/vant/latest-v2?style=flat-square) | Bugfix only |
| Vant 1 | Vue 2 | `2018.03` | ![](https://img.shields.io/npm/v/vant/latest-v1?style=flat-square) | End of life |
## Links ## Links
### Official Ecosystem ### Official Ecosystem
@ -41,16 +52,15 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
| --- | --- | | --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI | | [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos | | [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | Scaffold for UI library | | [vant-cli](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli) | Scaffold for UI library |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant icons | | [vant-icons](https://github.com/vant-ui/vant/tree/3.x/packages/vant-icons) | Vant icons |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers | | [vant-touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator) | Using vant in desktop browsers |
### Community Ecosystem ### Community Ecosystem
| Project | Description | | Project | Description |
| --- | --- | | --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant | | [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | React Mobile UI Components Library |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI | | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro | | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI | | [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
@ -61,7 +71,7 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
- [Feedback](https://github.com/vant-ui/vant/issues) - [Feedback](https://github.com/vant-ui/vant/issues)
- [Changelog](#/en-US/changelog) - [Changelog](#/en-US/changelog)
- [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) - [Discussions](https://github.com/vant-ui/vant/discussions)
## Contribution ## Contribution
@ -83,7 +93,7 @@ Thanks to the following friends for their contributions to Vant:
### Contribution Guide ### Contribution Guide
Please make sure to read the [Contributing Guide](https://github.com/vant-ui/vant/blob/dev/.github/CONTRIBUTING.md) before making a pull request. Please make sure to read the [Contributing Guide](https://github.com/vant-ui/vant/blob/3.x/.github/CONTRIBUTING.md) before making a pull request.
### LICENSE ### LICENSE

View File

@ -25,7 +25,7 @@ Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
- 🍭 支持主题定制,内置 700+ 个主题变量 - 🍭 支持主题定制,内置 700+ 个主题变量
- 🍭 支持按需引入和 Tree Shaking - 🍭 支持按需引入和 Tree Shaking
- 🍭 支持无障碍访问(持续改进中) - 🍭 支持无障碍访问(持续改进中)
- 🍭 支持深色模式(从 [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/zh-CN/config-provider) 开始支持) - 🍭 支持深色模式
- 🍭 支持服务器端渲染 - 🍭 支持服务器端渲染
- 🌍 支持国际化,内置 20+ 种语言包 - 🌍 支持国际化,内置 20+ 种语言包
@ -43,6 +43,17 @@ Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。
Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。 Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。
### 维护状态
目前 Vant 各个版本的维护状态如下:
| 名称 | 框架 | 发布时间 | 最新版 | 维护状态 |
| --- | --- | --- | --- | --- |
| Vant 4 | Vue 3 | `2022.11` | ![](https://img.shields.io/npm/v/vant/latest?style=flat-square) | 持续迭代新功能 |
| Vant 3 | Vue 3 | `2020.12` | ![](https://img.shields.io/npm/v/vant/latest-v3?style=flat-square) | 停止迭代新功能bug 会被处理和修复 |
| Vant 2 | Vue 2 | `2019.06` | ![](https://img.shields.io/npm/v/vant/latest-v2?style=flat-square) | 停止迭代新功能,重要 bug 会被处理和修复 |
| Vant 1 | Vue 2 | `2018.03` | ![](https://img.shields.io/npm/v/vant/latest-v1?style=flat-square) | 停止维护,不再接受 PR |
## 链接 ## 链接
### 官方生态 ### 官方生态
@ -53,9 +64,9 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| --- | --- | | --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 | | [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 | | [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 | | [vant-cli](https://github.com/vant-ui/vant/tree/3.x/packages/vant-cli) | 开箱即用的组件库搭建工具 |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant 图标库 | | [vant-icons](https://github.com/vant-ui/vant/tree/3.x/packages/vant-icons) | Vant 图标库 |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 | | [vant-touch-emulator](https://github.com/vant-ui/vant/tree/3.x/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
### 社区生态 ### 社区生态
@ -64,7 +75,6 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| 项目 | 描述 | | 项目 | 描述 |
| --- | --- | | --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 移动端组件库 | | [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 移动端组件库 |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | 基于 Vant 的 React 版本移动端 UI 组件库 |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 | | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 | | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 | | [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
@ -75,8 +85,8 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
- [意见反馈](https://github.com/vant-ui/vant/issues) - [意见反馈](https://github.com/vant-ui/vant/issues)
- [更新日志](#/zh-CN/changelog) - [更新日志](#/zh-CN/changelog)
- [码云镜像](https://gitee.com/vant-contrib/vant) - [码云镜像仓库](https://gitee.com/vant-contrib/vant)
- [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link) - [Discussions 讨论区](https://github.com/vant-ui/vant/discussions)
## 贡献 ## 贡献

View File

@ -10,7 +10,7 @@ Vant use [Less](http://lesscss.org/) as css preprocessoryou can override the
### Less variables ### Less variables
There are some [basic variables](<(https://github.com/vant-ui/vant/blob/dev/packages/vant/src/style/var.less)>) below, for component less variables, please refer to the documentation of each component, or view the `var.less` file in the component source directory. There are some [basic variables](<(https://github.com/vant-ui/vant/blob/3.x/packages/vant/src/style/var.less)>) below, for component less variables, please refer to the documentation of each component, or view the `var.less` file in the component source directory.
```less ```less
// Color Palette // Color Palette

View File

@ -16,7 +16,7 @@ Vant 提供了一套默认主题CSS 命名采用 BEM 的风格,方便使用
Vant 使用了 [Less](http://lesscss.org/) 对样式进行预处理,并内置了一些样式变量,通过替换样式变量即可定制你自己需要的主题。 Vant 使用了 [Less](http://lesscss.org/) 对样式进行预处理,并内置了一些样式变量,通过替换样式变量即可定制你自己需要的主题。
下面是所有的[基础样式变量](https://github.com/vant-ui/vant/blob/dev/packages/vant/src/style/var.less),组件的样式变量请参考各个组件的文档,或查看组件源码目录下的 `var.less` 文件。 下面是所有的[基础样式变量](https://github.com/vant-ui/vant/blob/3.x/packages/vant/src/style/var.less),组件的样式变量请参考各个组件的文档,或查看组件源码目录下的 `var.less` 文件。
```less ```less
// Color Palette // Color Palette

View File

@ -1,6 +1,6 @@
{ {
"name": "vant", "name": "vant",
"version": "3.6.2", "version": "3.6.12",
"description": "Lightweight Mobile UI Components built on Vue", "description": "Lightweight Mobile UI Components built on Vue",
"main": "lib/vant.cjs.js", "main": "lib/vant.cjs.js",
"module": "es/index.mjs", "module": "es/index.mjs",
@ -12,13 +12,16 @@
"es", "es",
"lib" "lib"
], ],
"npm": {
"tag": "latest-v3"
},
"scripts": { "scripts": {
"dev": "vant-cli dev", "dev": "vant-cli dev",
"lint": "vant-cli lint", "lint": "vant-cli lint",
"test": "vant-cli test", "test": "vant-cli test",
"build": "vant-cli build", "build": "vant-cli build",
"build:site": "vant-cli build-site", "build:site": "vant-cli build-site",
"release": "cp ../../README.md ./ && vant-cli release && rm ./README.md", "release": "cp ../../README.md ./ && vant-cli release --tag latest-v3 && rm ./README.md",
"release:site": "pnpm build:site && npx gh-pages -d site-dist --add", "release:site": "pnpm build:site && npx gh-pages -d site-dist --add",
"test:watch": "vant-cli test --watch", "test:watch": "vant-cli test --watch",
"test:coverage": "open test/coverage/index.html" "test:coverage": "open test/coverage/index.html"

View File

@ -52,7 +52,7 @@ export default {
### @vant/area-data ### @vant/area-data
Vant officially provides a default China area data, which can be imported through [@vant/area-data](https://github.com/vant-ui/vant/tree/dev/packages/vant-area-data): Vant officially provides a default China area data, which can be imported through [@vant/area-data](https://github.com/vant-ui/vant/tree/3.x/packages/vant-area-data):
```bash ```bash
# with npm # with npm

View File

@ -54,7 +54,7 @@ const areaList = {
### @vant/area-data ### @vant/area-data
Vant 官方提供了一份默认的中国省市区数据,可以通过 [@vant/area-data](https://github.com/vant-ui/vant/tree/dev/packages/vant-area-data) 引入: Vant 官方提供了一份默认的中国省市区数据,可以通过 [@vant/area-data](https://github.com/vant-ui/vant/tree/3.x/packages/vant-area-data) 引入:
```bash ```bash
# 通过 npm # 通过 npm

View File

@ -1 +1 @@
// 已迁移至 https://github.com/vant-ui/vant/tree/dev/packages/vant-area-data // 已迁移至 https://github.com/vant-ui/vant/tree/3.x/packages/vant-area-data

View File

@ -111,7 +111,7 @@ exports[`should update tabs when previous tab is clicked 1`] = `
<div style="transition-duration: 0ms; transform: translateX(0px); width: 200px;" <div style="transition-duration: 0ms; transform: translateX(0px); width: 200px;"
class="van-swipe__track" class="van-swipe__track"
> >
<div class="van-swipe-item van-tab__panel-wrapper van-tab__panel-wrapper--inactive" <div class="van-swipe-item van-tab__panel-wrapper"
id="van-tab" id="van-tab"
role="tabpanel" role="tabpanel"
tabindex="-1" tabindex="-1"

View File

@ -124,7 +124,7 @@ export default defineComponent({
} }
if (props.isLink) { if (props.isLink) {
const name = props.arrowDirection const name = props.arrowDirection && props.arrowDirection !== 'right'
? `arrow-${props.arrowDirection}` ? `arrow-${props.arrowDirection}`
: 'arrow'; : 'arrow';
return <Icon name={name} class={bem('right-icon')} />; return <Icon name={name} class={bem('right-icon')} />;

View File

@ -63,7 +63,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'year') { if (type === 'year') {
@ -103,7 +103,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'month') { if (type === 'month') {
@ -165,7 +165,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
return { return {
minDate: new Date(2020, 0, 1), minDate: new Date(2020, 0, 1),
maxDate: new Date(2025, 10, 1), maxDate: new Date(2025, 10, 1),
@ -192,7 +192,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
return { return {
minDate: new Date(2020, 0, 1), minDate: new Date(2020, 0, 1),
maxDate: new Date(2025, 10, 1), maxDate: new Date(2025, 10, 1),
@ -252,7 +252,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'year') { if (type === 'year') {

View File

@ -67,7 +67,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'year') { if (type === 'year') {
@ -109,7 +109,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'month') { if (type === 'month') {
@ -175,7 +175,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
return { return {
minDate: new Date(2020, 0, 1), minDate: new Date(2020, 0, 1),
maxDate: new Date(2025, 10, 1), maxDate: new Date(2025, 10, 1),
@ -204,7 +204,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
return { return {
minDate: new Date(2020, 0, 1), minDate: new Date(2020, 0, 1),
maxDate: new Date(2025, 10, 1), maxDate: new Date(2025, 10, 1),
@ -261,7 +261,7 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const currentDate = ref(new Date()); const currentDate = ref(new Date(2020, 0, 1));
const formatter = (type, val) => { const formatter = (type, val) => {
if (type === 'year') { if (type === 'year') {

View File

@ -216,7 +216,7 @@ export default {
| ---------------- | -------------- | | ---------------- | -------------- |
| default | Custom message | | default | Custom message |
| title | Custom title | | title | Custom title |
| footer `v3.0.10` | Custom footer | | footer `v3.0.11` | Custom footer |
### Types ### Types

View File

@ -278,7 +278,7 @@ export default {
| ---------------- | ------------------ | | ---------------- | ------------------ |
| default | 自定义内容 | | default | 自定义内容 |
| title | 自定义标题 | | title | 自定义标题 |
| footer `v3.0.10` | 自定义底部按钮区域 | | footer `v3.0.11` | 自定义底部按钮区域 |
### 类型定义 ### 类型定义

View File

@ -282,6 +282,15 @@ export default defineComponent({
if (modelValue && getStringLength(modelValue) === +maxlength) { if (modelValue && getStringLength(modelValue) === +maxlength) {
return modelValue; return modelValue;
} }
// Remove redundant interpolated values,
// make it consistent with the native input maxlength behavior.
const selectionEnd = inputRef.value?.selectionEnd;
if (state.focused && selectionEnd) {
const valueArr = [...value];
const exceededLength = valueArr.length - +maxlength;
valueArr.splice(selectionEnd - exceededLength, exceededLength);
return valueArr.join('');
}
return cutString(value, +maxlength); return cutString(value, +maxlength);
} }
return value; return value;
@ -291,19 +300,63 @@ export default defineComponent({
value: string, value: string,
trigger: FieldFormatTrigger = 'onChange' trigger: FieldFormatTrigger = 'onChange'
) => { ) => {
const originalValue = value;
value = limitValueLength(value); value = limitValueLength(value);
// When the value length exceeds maxlength,
// record the excess length for correcting the cursor position.
// https://github.com/youzan/vant/issues/11289
const limitDiffLen =
getStringLength(originalValue) - getStringLength(value);
if (props.type === 'number' || props.type === 'digit') { if (props.type === 'number' || props.type === 'digit') {
const isNumber = props.type === 'number'; const isNumber = props.type === 'number';
value = formatNumber(value, isNumber, isNumber); value = formatNumber(value, isNumber, isNumber);
} }
let formatterDiffLen = 0;
if (props.formatter && trigger === props.formatTrigger) { if (props.formatter && trigger === props.formatTrigger) {
value = props.formatter(value); const { formatter, maxlength } = props;
value = formatter(value);
// The length of the formatted value may exceed maxlength.
if (isDef(maxlength) && getStringLength(value) > maxlength) {
value = cutString(value, +maxlength);
}
if (inputRef.value && state.focused) {
const { selectionEnd } = inputRef.value;
// The value before the cursor of the original value.
const bcoVal = cutString(originalValue, selectionEnd!);
// Record the length change of `bcoVal` after formatting,
// which is used to correct the cursor position.
formatterDiffLen =
getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
}
} }
if (inputRef.value && inputRef.value.value !== value) { if (inputRef.value && inputRef.value.value !== value) {
// When the input is focused, correct the cursor position.
if (state.focused) {
let { selectionStart, selectionEnd } = inputRef.value;
inputRef.value.value = value; inputRef.value.value = value;
if (isDef(selectionStart) && isDef(selectionEnd)) {
const valueLen = getStringLength(value);
if (limitDiffLen) {
selectionStart -= limitDiffLen;
selectionEnd -= limitDiffLen;
} else if (formatterDiffLen) {
selectionStart += formatterDiffLen;
selectionEnd += formatterDiffLen;
}
inputRef.value.setSelectionRange(
Math.min(selectionStart, valueLen),
Math.min(selectionEnd, valueLen)
);
}
} else {
inputRef.value.value = value;
}
} }
if (value !== props.modelValue) { if (value !== props.modelValue) {

View File

@ -4,6 +4,7 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-tabs van-tabs--line"> <div class="van-tabs van-tabs--line">
<div> <div>
<div class="van-sticky"> <div class="van-sticky">
<div>
<div class="van-tabs__wrap"> <div class="van-tabs__wrap">
<div role="tablist" <div role="tablist"
class="van-tabs__nav van-tabs__nav--line" class="van-tabs__nav van-tabs__nav--line"
@ -61,6 +62,7 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="van-tabs__content"> <div class="van-tabs__content">
<div id="van-tab" <div id="van-tab"
role="tabpanel" role="tabpanel"

View File

@ -157,6 +157,9 @@ export default defineComponent({
rootHeight={state.rootHeight} rootHeight={state.rootHeight}
onScale={emitScale} onScale={emitScale}
onClose={emitClose} onClose={emitClose}
v-slots={{
image: slots.image,
}}
/> />
))} ))}
</Swipe> </Swipe>

View File

@ -47,7 +47,7 @@ export default defineComponent({
emits: ['scale', 'close'], emits: ['scale', 'close'],
setup(props, { emit }) { setup(props, { emit, slots }) {
const state = reactive({ const state = reactive({
scale: 1, scale: 1,
moveX: 0, moveX: 0,
@ -293,6 +293,11 @@ export default defineComponent({
onTouchend={onTouchEnd} onTouchend={onTouchEnd}
onTouchcancel={onTouchEnd} onTouchcancel={onTouchEnd}
> >
{slots.image ? (
<div class={bem('image-wrap')}>
{slots.image({ src: props.src })}
</div>
) : (
<Image <Image
v-slots={imageSlots} v-slots={imageSlots}
src={props.src} src={props.src}
@ -301,6 +306,7 @@ export default defineComponent({
style={imageStyle.value} style={imageStyle.value}
onLoad={onLoad} onLoad={onLoad}
/> />
)}
</SwipeItem> </SwipeItem>
); );
}; };

View File

@ -118,6 +118,39 @@ export default {
}; };
``` ```
### Use image slot
When using ImagePreview component, you can custom the image through the `image` slot, such as render a video content.
```html
<van-image-preview v-model:show="show" :images="images">
<template #image="{ src }">
<video style="width: 100%;" controls>
<source :src="src" />
</video>
</template>
</van-image-preview>
```
```js
import { ref } from 'vue';
export default {
setup() {
const show = ref(false);
const images = [
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
];
return {
show,
images,
};
},
};
```
## API ## API
### Options ### Options
@ -218,6 +251,7 @@ imagePreviewRef.value?.swipeTo(1);
| --- | --- | --- | | --- | --- | --- |
| index | Custom index | { index: index of current image } | | index | Custom index | { index: index of current image } |
| cover | Custom content that covers the image preview | - | | cover | Custom content that covers the image preview | - |
| image `v3.6.5` | Custom image content | { src: current image src } |
### onClose Parameters ### onClose Parameters

View File

@ -172,6 +172,39 @@ export default {
}; };
``` ```
### 使用 image 插槽
当以组件调用的方式使用 ImagePreview 时,可以通过 `image` 插槽来插入自定义的内容,比如展示一个视频内容。
```html
<van-image-preview v-model:show="show" :images="images">
<template #image="{ src }">
<video style="width: 100%;" controls>
<source :src="src" />
</video>
</template>
</van-image-preview>
```
```js
import { ref } from 'vue';
export default {
setup() {
const show = ref(false);
const images = [
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
];
return {
show,
images,
};
},
};
```
## API ## API
### Options ### Options
@ -276,9 +309,10 @@ imagePreviewRef.value?.swipeTo(1);
通过组件调用 `ImagePreview` 时,支持以下插槽: 通过组件调用 `ImagePreview` 时,支持以下插槽:
| 名称 | 说明 | 参数 | | 名称 | 说明 | 参数 |
| ----- | ------------------------------ | ------------------------- | | -------------- | ------------------------------ | ------------------------- |
| index | 自定义页码内容 | { index: 当前图片的索引 } | | index | 自定义页码内容 | { index: 当前图片的索引 } |
| cover | 自定义覆盖在图片预览上方的内容 | - | | cover | 自定义覆盖在图片预览上方的内容 | - |
| image `v3.6.5` | 自定义图片内容 | { src: 当前资源地址 } |
### onClose 回调参数 ### onClose 回调参数

View File

@ -17,6 +17,7 @@ const t = useTranslate({
customConfig: '传入配置项', customConfig: '传入配置项',
startPosition: '指定初始位置', startPosition: '指定初始位置',
componentCall: '组件调用', componentCall: '组件调用',
useImageSlot: '使用 image 插槽',
index: (index: number) => `${index + 1}`, index: (index: number) => `${index + 1}`,
}, },
'en-US': { 'en-US': {
@ -28,6 +29,7 @@ const t = useTranslate({
customConfig: 'Custom Config', customConfig: 'Custom Config',
startPosition: 'Set Start Position', startPosition: 'Set Start Position',
componentCall: 'Component Call', componentCall: 'Component Call',
useImageSlot: 'Use image slot',
index: (index: number) => `Page: ${index}`, index: (index: number) => `Page: ${index}`,
}, },
}); });
@ -39,9 +41,18 @@ const images = [
cdnURL('apple-4.jpeg'), cdnURL('apple-4.jpeg'),
]; ];
const imagesSlot = [
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
'https://www.w3school.com.cn/i/movie.ogg',
];
const show = ref(false); const show = ref(false);
const index = ref(0); const index = ref(0);
const showSlot = ref(false);
const onClose = () => Toast(t('closed')); const onClose = () => Toast(t('closed'));
const beforeClose = () => const beforeClose = () =>
@ -59,6 +70,10 @@ const onChange = (newIndex: number) => {
index.value = newIndex; index.value = newIndex;
}; };
const showComponentCallSlot = () => {
showSlot.value = true;
};
const showImagePreview = (options: Partial<ImagePreviewOptions> = {}) => { const showImagePreview = (options: Partial<ImagePreviewOptions> = {}) => {
const instance = ImagePreview({ const instance = ImagePreview({
images, images,
@ -110,4 +125,19 @@ const showImagePreview = (options: Partial<ImagePreviewOptions> = {}) => {
<template #index>{{ t('index', index) }}</template> <template #index>{{ t('index', index) }}</template>
</van-image-preview> </van-image-preview>
</demo-block> </demo-block>
<demo-block card :title="t('useImageSlot')">
<van-cell
is-link
:value="t('useImageSlot')"
@click="showComponentCallSlot"
/>
<van-image-preview v-model:show="showSlot" :images="imagesSlot">
<template #image="{ src }">
<video style="width: 100%" controls>
<source :src="src" />
</video>
</template>
</van-image-preview>
</demo-block>
</template> </template>

View File

@ -38,7 +38,8 @@
left: 0; left: 0;
} }
&__image { &__image,
&__image-wrap {
width: 100%; width: 100%;
transition-property: transform; transition-property: transform;
@ -47,7 +48,8 @@
height: 100%; height: 100%;
} }
img { img,
video {
// disable desktop browser image drag // disable desktop browser image drag
-webkit-user-drag: none; -webkit-user-drag: none;
} }

View File

@ -254,3 +254,36 @@ test('zoom out', async () => {
restore(); restore();
}); });
test('should render image slot correctly', async () => {
const wrapper = mount(ImagePreviewComponent, {
props: {
show: true,
images,
},
slots: {
image: ({ src }) => `<img class="test-img" src="${src}" />`,
},
});
await later();
expect(wrapper.html().includes('test-img')).toBeTruthy();
});
test('should render image slot correctly 2', async () => {
const wrapper = mount(ImagePreviewComponent, {
props: {
show: true,
images,
},
slots: {
image: ({ src }) =>
`<video style="width: 100%;" controls><source src="${src}" /></video>`,
},
});
await later();
expect(wrapper.html().includes('video')).toBeTruthy();
});

View File

@ -6,6 +6,7 @@
import { useRect } from '@vant/use'; import { useRect } from '@vant/use';
import { loadImageAsync } from './util'; import { loadImageAsync } from './util';
import { noop } from '../../utils'; import { noop } from '../../utils';
import { h } from 'vue';
export default (lazyManager) => ({ export default (lazyManager) => ({
props: { props: {
@ -15,15 +16,13 @@ export default (lazyManager) => ({
default: 'img', default: 'img',
}, },
}, },
render(h) { render() {
return h( return h(
this.tag, this.tag,
{ {
attrs: {
src: this.renderSrc, src: this.renderSrc,
}, },
}, this.$slots.default?.()
this.$slots.default
); );
}, },
data() { data() {

View File

@ -53,7 +53,7 @@ export default defineComponent({
setup(props, { emit, slots }) { setup(props, { emit, slots }) {
// use sync innerLoading state to avoid repeated loading in some edge cases // use sync innerLoading state to avoid repeated loading in some edge cases
const loading = ref(false); const loading = ref(props.loading);
const root = ref<HTMLElement>(); const root = ref<HTMLElement>();
const placeholder = ref<HTMLElement>(); const placeholder = ref<HTMLElement>();
const tabStatus = useTabStatus(); const tabStatus = useTabStatus();

View File

@ -72,7 +72,7 @@ Current supported languages:
| Traditional Chinese (HK) | zh-HK | - | | Traditional Chinese (HK) | zh-HK | - |
| Traditional Chinese (TW) | zh-TW | - | | Traditional Chinese (TW) | zh-TW | - |
> View all language configs [Here](https://github.com/vant-ui/vant/tree/dev/packages/vant/src/locale/lang). > View all language configs [Here](https://github.com/vant-ui/vant/tree/3.x/packages/vant/src/locale/lang).
### Add new language ### Add new language

View File

@ -73,7 +73,7 @@ Locale.add(messages);
| 繁體中文(港) | zh-HK | - | | 繁體中文(港) | zh-HK | - |
| 繁體中文(台) | zh-TW | - | | 繁體中文(台) | zh-TW | - |
> 在 [这里](https://github.com/vant-ui/vant/tree/dev/packages/vant/src/locale/lang) 查看所有的语言包源文件。 > 在 [这里](https://github.com/vant-ui/vant/tree/3.x/packages/vant/src/locale/lang) 查看所有的语言包源文件。
## 常见问题 ## 常见问题

View File

@ -79,6 +79,8 @@ function shuffle(array: unknown[]) {
export default defineComponent({ export default defineComponent({
name, name,
inheritAttrs: false,
props: numberKeyboardProps, props: numberKeyboardProps,
emits: [ emits: [
@ -91,7 +93,7 @@ export default defineComponent({
'update:modelValue', 'update:modelValue',
], ],
setup(props, { emit, slots }) { setup(props, { emit, slots, attrs }) {
const root = ref<HTMLElement>(); const root = ref<HTMLElement>();
const genBasicKeys = () => { const genBasicKeys = () => {
@ -282,6 +284,7 @@ export default defineComponent({
})} })}
onAnimationend={onAnimationEnd} onAnimationend={onAnimationEnd}
onTouchstartPassive={stopPropagation} onTouchstartPassive={stopPropagation}
{...attrs}
> >
{Title} {Title}
<div class={bem('body')}> <div class={bem('body')}>

View File

@ -246,3 +246,18 @@ test('should not emit close event after clicking close button when blur-on-close
clickKey(wrapper.findAll('.van-key')[12]); clickKey(wrapper.findAll('.van-key')[12]);
expect(wrapper.emitted('blur')).toBeFalsy(); expect(wrapper.emitted('blur')).toBeFalsy();
}); });
test('should inherit attrs when using teleport prop', () => {
const root = document.createElement('div');
mount(NumberKeyboard, {
props: {
teleport: root,
},
attrs: {
class: 'foo',
},
});
const el = root.querySelector('.van-number-keyboard');
expect(el?.classList.contains('foo')).toBeTruthy();
});

View File

@ -21,7 +21,7 @@ import {
import { TABS_KEY } from '../tabs/Tabs'; import { TABS_KEY } from '../tabs/Tabs';
// Composables // Composables
import { useParent } from '@vant/use'; import { doubleRaf, useParent } from '@vant/use';
import { useId } from '../composables/use-id'; import { useId } from '../composables/use-id';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
import { routeProps } from '../composables/use-route'; import { routeProps } from '../composables/use-route';
@ -84,6 +84,21 @@ export default defineComponent({
return isActive; return isActive;
}); });
const hasInactiveClass = ref(!active.value);
watch(active, (val) => {
if (val) {
hasInactiveClass.value = false;
} else {
// mark tab as inactive until the active tab is rendered
// to avoid incorrect scroll position or other render issue
// https://github.com/youzan/vant/issues/11050
doubleRaf(() => {
hasInactiveClass.value = true;
});
}
});
watch( watch(
() => props.title, () => props.title,
() => { () => {
@ -109,7 +124,7 @@ export default defineComponent({
<SwipeItem <SwipeItem
id={id} id={id}
role="tabpanel" role="tabpanel"
class={bem('panel-wrapper', { inactive: !active.value })} class={bem('panel-wrapper', { inactive: hasInactiveClass.value })}
tabindex={active.value ? 0 : -1} tabindex={active.value ? 0 : -1}
aria-hidden={!active.value} aria-hidden={!active.value}
aria-labelledby={label} aria-labelledby={label}

View File

@ -546,6 +546,7 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-tabs van-tabs--line"> <div class="van-tabs van-tabs--line">
<div> <div>
<div class="van-sticky"> <div class="van-sticky">
<div>
<div class="van-tabs__wrap"> <div class="van-tabs__wrap">
<div role="tablist" <div role="tablist"
class="van-tabs__nav van-tabs__nav--line" class="van-tabs__nav van-tabs__nav--line"
@ -603,6 +604,7 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="van-tabs__content"> <div class="van-tabs__content">
<div id="van-tab" <div id="van-tab"
role="tabpanel" role="tabpanel"
@ -1096,6 +1098,7 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-tabs van-tabs--line"> <div class="van-tabs van-tabs--line">
<div> <div>
<div class="van-sticky"> <div class="van-sticky">
<div>
<div class="van-tabs__wrap"> <div class="van-tabs__wrap">
<div role="tablist" <div role="tablist"
class="van-tabs__nav van-tabs__nav--line van-tabs__nav--complete" class="van-tabs__nav van-tabs__nav--line van-tabs__nav--complete"
@ -1197,6 +1200,7 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="van-tabs__content"> <div class="van-tabs__content">
<div id="van-tab" <div id="van-tab"
role="tabpanel" role="tabpanel"

View File

@ -470,7 +470,7 @@ exports[`swipe switch tab after swiping tab content 2`] = `
<div style="transition-duration: 300ms; transform: translateX(-100px); width: 300px;" <div style="transition-duration: 300ms; transform: translateX(-100px); width: 300px;"
class="van-swipe__track" class="van-swipe__track"
> >
<div class="van-swipe-item van-tab__panel-wrapper van-tab__panel-wrapper--inactive" <div class="van-swipe-item van-tab__panel-wrapper"
id="van-tab" id="van-tab"
role="tabpanel" role="tabpanel"
tabindex="-1" tabindex="-1"
@ -560,7 +560,7 @@ exports[`swipe switch tab after swiping tab content 3`] = `
<div style="transition-duration: 300ms; transform: translateX(-200px); width: 300px;" <div style="transition-duration: 300ms; transform: translateX(-200px); width: 300px;"
class="van-swipe__track" class="van-swipe__track"
> >
<div class="van-swipe-item van-tab__panel-wrapper van-tab__panel-wrapper--inactive" <div class="van-swipe-item van-tab__panel-wrapper"
id="van-tab" id="van-tab"
role="tabpanel" role="tabpanel"
tabindex="-1" tabindex="-1"

View File

@ -239,7 +239,10 @@ export default defineComponent({
} }
}; };
const setCurrentIndex = (currentIndex: number) => { const setCurrentIndex = (
currentIndex: number,
skipScrollIntoView?: boolean
) => {
const newIndex = findAvailableTab(currentIndex); const newIndex = findAvailableTab(currentIndex);
if (!isDef(newIndex)) { if (!isDef(newIndex)) {
@ -250,8 +253,15 @@ export default defineComponent({
const newName = getTabName(newTab, newIndex); const newName = getTabName(newTab, newIndex);
const shouldEmitChange = state.currentIndex !== null; const shouldEmitChange = state.currentIndex !== null;
if (state.currentIndex !== newIndex) {
state.currentIndex = newIndex; state.currentIndex = newIndex;
if (!skipScrollIntoView) {
scrollIntoView();
}
setLine();
}
if (newName !== props.active) { if (newName !== props.active) {
emit('update:active', newName); emit('update:active', newName);
@ -259,16 +269,26 @@ export default defineComponent({
emit('change', newName, newTab.title); emit('change', newName, newTab.title);
} }
} }
// scroll to correct position
if (stickyFixed && !props.scrollspy) {
setRootScrollTop(
Math.ceil(getElementTop(root.value!) - offsetTopPx.value)
);
}
}; };
// correct the index of active tab // correct the index of active tab
const setCurrentIndexByName = (name: Numeric) => { const setCurrentIndexByName = (
name: Numeric,
skipScrollIntoView?: boolean
) => {
const matched = children.find( const matched = children.find(
(tab, index) => getTabName(tab, index) === name (tab, index) => getTabName(tab, index) === name
); );
const index = matched ? children.indexOf(matched) : 0; const index = matched ? children.indexOf(matched) : 0;
setCurrentIndex(index); setCurrentIndex(index, skipScrollIntoView);
}; };
const scrollToCurrentContent = (immediate = false) => { const scrollToCurrentContent = (immediate = false) => {
@ -397,10 +417,11 @@ export default defineComponent({
}; };
const renderHeader = () => { const renderHeader = () => {
const { type, border } = props; const { type, border, sticky } = props;
return (
const Header = [
<div <div
ref={wrapRef} ref={sticky ? undefined : wrapRef}
class={[ class={[
bem('wrap'), bem('wrap'),
{ [BORDER_TOP_BOTTOM]: type === 'line' && border }, { [BORDER_TOP_BOTTOM]: type === 'line' && border },
@ -421,8 +442,14 @@ export default defineComponent({
{renderLine()} {renderLine()}
{slots['nav-right']?.()} {slots['nav-right']?.()}
</div> </div>
</div> </div>,
); slots['nav-bottom']?.(),
];
if (sticky) {
return <div ref={wrapRef}>{Header}</div>;
}
return Header;
}; };
watch([() => props.color, windowWidth], setLine); watch([() => props.color, windowWidth], setLine);
@ -449,23 +476,8 @@ export default defineComponent({
} }
); );
watch(
() => state.currentIndex,
() => {
scrollIntoView();
setLine();
// scroll to correct position
if (stickyFixed && !props.scrollspy) {
setRootScrollTop(
Math.ceil(getElementTop(root.value!) - offsetTopPx.value)
);
}
}
);
const init = () => { const init = () => {
setCurrentIndexByName(props.active); setCurrentIndexByName(props.active, true);
nextTick(() => { nextTick(() => {
state.inited = true; state.inited = true;
if (wrapRef.value) { if (wrapRef.value) {
@ -514,10 +526,9 @@ export default defineComponent({
onScroll={onStickyScroll} onScroll={onStickyScroll}
> >
{renderHeader()} {renderHeader()}
{slots['nav-bottom']?.()}
</Sticky> </Sticky>
) : ( ) : (
[renderHeader(), slots['nav-bottom']?.()] renderHeader()
)} )}
<TabsContent <TabsContent
ref={contentRef} ref={contentRef}

View File

@ -41,15 +41,18 @@ export default {
children: [ children: [
{ text: 'Delaware', id: 1 }, { text: 'Delaware', id: 1 },
{ text: 'Florida', id: 2 }, { text: 'Florida', id: 2 },
{ text: 'Georqia', id: 3, disabled: true },
], ],
}, },
{ {
text: 'Group 2', text: 'Group 2',
children: [ children: [
{ text: 'Alabama', id: 5 }, { text: 'Alabama', id: 4 },
{ text: 'Kansas', id: 6 }, { text: 'Kansas', id: 5 },
{ text: 'Louisiana', id: 6 },
], ],
}, },
{ text: 'Group 3', disabled: true },
]; ];
return { return {
@ -84,15 +87,18 @@ export default {
children: [ children: [
{ text: 'Delaware', id: 1 }, { text: 'Delaware', id: 1 },
{ text: 'Florida', id: 2 }, { text: 'Florida', id: 2 },
{ text: 'Georqia', id: 3, disabled: true },
], ],
}, },
{ {
text: 'Group 2', text: 'Group 2',
children: [ children: [
{ text: 'Alabama', id: 5 }, { text: 'Alabama', id: 4 },
{ text: 'Kansas', id: 6 }, { text: 'Kansas', id: 5 },
{ text: 'Louisiana', id: 6 },
], ],
}, },
{ text: 'Group 3', disabled: true },
]; ];
return { return {
@ -158,8 +164,24 @@ export default {
return { return {
activeIndex, activeIndex,
items: [ items: [
{ text: 'Group 1', children: [], dot: true }, {
{ text: 'Group 2', children: [], badge: 5 }, text: 'Group 1',
children: [
{ text: 'Delaware', id: 1 },
{ text: 'Florida', id: 2 },
{ text: 'Georqia', id: 3, disabled: true },
],
dot: true,
},
{
text: 'Group 2',
children: [
{ text: 'Alabama', id: 4 },
{ text: 'Kansas', id: 5 },
{ text: 'Louisiana', id: 6 },
],
badge: 5,
},
], ],
}; };
}, },

View File

@ -43,15 +43,18 @@ export default {
children: [ children: [
{ text: '杭州', id: 1 }, { text: '杭州', id: 1 },
{ text: '温州', id: 2 }, { text: '温州', id: 2 },
{ text: '宁波', id: 3, disabled: true },
], ],
}, },
{ {
text: '江苏', text: '江苏',
children: [ children: [
{ text: '南京', id: 5 }, { text: '南京', id: 4 },
{ text: '无锡', id: 6 }, { text: '无锡', id: 5 },
{ text: '徐州', id: 6 },
], ],
}, },
{ text: '福建', disabled: true },
]; ];
return { return {
@ -88,15 +91,18 @@ export default {
children: [ children: [
{ text: '杭州', id: 1 }, { text: '杭州', id: 1 },
{ text: '温州', id: 2 }, { text: '温州', id: 2 },
{ text: '宁波', id: 3, disabled: true },
], ],
}, },
{ {
text: '江苏', text: '江苏',
children: [ children: [
{ text: '南京', id: 5 }, { text: '南京', id: 4 },
{ text: '无锡', id: 6 }, { text: '无锡', id: 5 },
{ text: '徐州', id: 6 },
], ],
}, },
{ text: '福建', disabled: true },
]; ];
return { return {
@ -166,8 +172,24 @@ export default {
return { return {
activeIndex, activeIndex,
items: [ items: [
{ text: '浙江', children: [], dot: true }, {
{ text: '江苏', children: [], badge: 5 }, text: '浙江',
children: [
{ text: '杭州', id: 1 },
{ text: '温州', id: 2 },
{ text: '宁波', id: 3, disabled: true },
],
dot: true,
},
{
text: '江苏',
children: [
{ text: '南京', id: 4 },
{ text: '无锡', id: 5 },
{ text: '徐州', id: 6 },
],
badge: 5,
},
], ],
}; };
}, },

View File

@ -12,39 +12,31 @@ const group1 = [
id: 3, id: 3,
disabled: true, disabled: true,
}, },
{
text: 'Indiana',
id: 4,
},
]; ];
const group2 = [ const group2 = [
{ {
text: 'Alabama', text: 'Alabama',
id: 5, id: 4,
}, },
{ {
text: 'Kansas', text: 'Kansas',
id: 6, id: 5,
}, },
{ {
text: 'Louisiana', text: 'Louisiana',
id: 7, id: 6,
},
{
text: 'Texas',
id: 8,
}, },
]; ];
const group3 = [ const group3 = [
{ {
text: 'Alabama', text: 'Alabama',
id: 9, id: 7,
}, },
{ {
text: 'Kansas', text: 'Kansas',
id: 10, id: 8,
}, },
]; ];

View File

@ -12,39 +12,31 @@ const zhejiang = [
id: 3, id: 3,
disabled: true, disabled: true,
}, },
{
text: '义乌',
id: 4,
},
]; ];
const jiangsu = [ const jiangsu = [
{ {
text: '南京', text: '南京',
id: 5, id: 4,
}, },
{ {
text: '无锡', text: '无锡',
id: 6, id: 5,
}, },
{ {
text: '徐州', text: '徐州',
id: 7, id: 6,
},
{
text: '苏州',
id: 8,
}, },
]; ];
const fujian = [ const fujian = [
{ {
text: '泉州', text: '泉州',
id: 9, id: 7,
}, },
{ {
text: '厦门', text: '厦门',
id: 10, id: 8,
}, },
]; ];

View File

@ -47,9 +47,6 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled"> <div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled">
Georqia Georqia
</div> </div>
<div class="van-ellipsis van-tree-select__item">
Indiana
</div>
</div> </div>
</div> </div>
</div> </div>
@ -101,9 +98,6 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled"> <div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled">
Georqia Georqia
</div> </div>
<div class="van-ellipsis van-tree-select__item">
Indiana
</div>
</div> </div>
</div> </div>
</div> </div>
@ -185,9 +179,6 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled"> <div class="van-ellipsis van-tree-select__item van-tree-select__item--disabled">
Georqia Georqia
</div> </div>
<div class="van-ellipsis van-tree-select__item">
Indiana
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -158,6 +158,7 @@ export default defineComponent({
file, file,
status: '', status: '',
message: '', message: '',
objectUrl: URL.createObjectURL(file)
}; };
if (contents[index]) { if (contents[index]) {
@ -175,6 +176,7 @@ export default defineComponent({
file: files as File, file: files as File,
status: '', status: '',
message: '', message: '',
objectUrl: URL.createObjectURL(files as File),
}; };
if (content) { if (content) {
@ -230,8 +232,8 @@ export default defineComponent({
const imageFiles = props.modelValue.filter(isImageFile); const imageFiles = props.modelValue.filter(isImageFile);
const images = imageFiles const images = imageFiles
.map((item) => { .map((item) => {
if (item.file && !item.url && item.status !== 'failed') { if (item.objectUrl && !item.url && item.status !== 'failed') {
item.url = URL.createObjectURL(item.file); item.url = item.objectUrl;
urls.push(item.url); urls.push(item.url);
} }
return item.url; return item.url;

View File

@ -111,7 +111,7 @@ export default defineComponent({
<Image <Image
v-slots={{ default: renderCover }} v-slots={{ default: renderCover }}
fit={imageFit} fit={imageFit}
src={item.content || item.url} src={item.objectUrl || item.content || item.url}
class={bem('preview-image')} class={bem('preview-image')}
width={Array.isArray(previewSize) ? previewSize[0] : previewSize} width={Array.isArray(previewSize) ? previewSize[0] : previewSize}
height={Array.isArray(previewSize) ? previewSize[1] : previewSize} height={Array.isArray(previewSize) ? previewSize[1] : previewSize}

View File

@ -8,6 +8,7 @@ export type UploaderResultType = 'dataUrl' | 'text' | 'file';
export type UploaderFileListItem = { export type UploaderFileListItem = {
url?: string; url?: string;
file?: File; file?: File;
objectUrl?: string;
content?: string; content?: string;
isImage?: boolean; isImage?: boolean;
status?: '' | 'uploading' | 'done' | 'failed'; status?: '' | 'uploading' | 'done' | 'failed';

View File

@ -63,7 +63,7 @@ export function filterFiles(
return { valid, invalid }; return { valid, invalid };
} }
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i; const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
export const isImageUrl = (url: string): boolean => IMAGE_REGEXP.test(url); export const isImageUrl = (url: string): boolean => IMAGE_REGEXP.test(url);

View File

@ -11,7 +11,7 @@ export default {
}, },
site: { site: {
publicPath: publicPath:
(typeof window === 'undefined' && process.env.PUBLIC_PATH) || '/vant/', (typeof window === 'undefined' && process.env.PUBLIC_PATH) || '/vant/v3/',
}, },
}, },
site: { site: {
@ -27,6 +27,12 @@ export default {
htmlMeta: { htmlMeta: {
'docsearch:version': 'v3', 'docsearch:version': 'v3',
}, },
headHtml: `<script>
if (location.host === 'youzan.github.io') {
location.href = location.href.replace('youzan.github.io', 'vant-ui.github.io');
}
</script>
`,
locales: { locales: {
'zh-CN': { 'zh-CN': {
title: 'Vant 3', title: 'Vant 3',