mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
Merge branch 'dev' into next
This commit is contained in:
commit
e2fe50250c
@ -18,10 +18,10 @@
|
||||
"devDependencies": {
|
||||
"@vant/cli": "workspace:*",
|
||||
"@vant/eslint-config": "workspace:*",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint": "^8.23.0",
|
||||
"husky": "^8.0.1",
|
||||
"nano-staged": "^0.8.0",
|
||||
"prettier": "^2.5.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"pnpm": {
|
||||
|
@ -32,15 +32,15 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/inquirer": "^8.1.3",
|
||||
"release-it": "^15.1.1",
|
||||
"typescript": "^4.7.4"
|
||||
"@types/inquirer": "^8.2.3",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"consola": "^2.11.3",
|
||||
"fast-glob": "^3.2.4",
|
||||
"fs-extra": "^10.0.0",
|
||||
"inquirer": "^8.0.0",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.1.0",
|
||||
"inquirer": "^8.2.4",
|
||||
"picocolors": "^1.0.0"
|
||||
},
|
||||
"release-it": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/area-data",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"description": "Vant 省市区数据",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.mjs",
|
||||
@ -36,9 +36,9 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.14.29",
|
||||
"release-it": "^15.1.1",
|
||||
"typescript": "^4.7.4"
|
||||
"esbuild": "^0.14.54",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -1150,10 +1150,10 @@ export const areaList = {
|
||||
232701: '漠河市',
|
||||
232721: '呼玛县',
|
||||
232722: '塔河县',
|
||||
232790: '松岭区',
|
||||
232791: '呼中区',
|
||||
232792: '加格达奇区',
|
||||
232793: '新林区',
|
||||
232761: '加格达奇区',
|
||||
232762: '松岭区',
|
||||
232763: '新林区',
|
||||
232764: '呼中区',
|
||||
310101: '黄浦区',
|
||||
310104: '徐汇区',
|
||||
310105: '长宁区',
|
||||
|
@ -39,56 +39,56 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@jest/types": "^27.5.1",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/less": "^3.0.3",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@jest/types": "^27",
|
||||
"vue": "^3.2.27",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"vue": "^3.2.38"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@docsearch/css": "^3.0.0",
|
||||
"@docsearch/js": "^3.0.0",
|
||||
"@types/jest": "^27.0.3",
|
||||
"@vant/eslint-config": "^3.3.2",
|
||||
"@vant/touch-emulator": "^1.3.2",
|
||||
"@vitejs/plugin-vue": "^3.0.1",
|
||||
"@vitejs/plugin-vue-jsx": "^2.0.0",
|
||||
"@babel/core": "^7.18.13",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@docsearch/css": "^3.2.1",
|
||||
"@docsearch/js": "^3.2.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@vant/eslint-config": "^3.5.0",
|
||||
"@vant/touch-emulator": "^1.4.0",
|
||||
"@vitejs/plugin-vue": "^3.0.3",
|
||||
"@vitejs/plugin-vue-jsx": "^2.0.1",
|
||||
"@vue/babel-plugin-jsx": "^1.1.1",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"commander": "^9.3.0",
|
||||
"autoprefixer": "^10.4.8",
|
||||
"commander": "^9.4.0",
|
||||
"consola": "^2.15.3",
|
||||
"conventional-changelog": "^3.1.24",
|
||||
"esbuild": "^0.14.29",
|
||||
"eslint": "^8.1.0",
|
||||
"conventional-changelog": "^3.1.25",
|
||||
"esbuild": "^0.14.54",
|
||||
"eslint": "^8.23.0",
|
||||
"execa": "^5.1.1",
|
||||
"fast-glob": "^3.2.7",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.1.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"highlight.js": "^11.3.1",
|
||||
"highlight.js": "^11.6.0",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^27.3.1",
|
||||
"jest-canvas-mock": "^2.3.1",
|
||||
"jest": "^27.5.1",
|
||||
"jest-canvas-mock": "^2.4.0",
|
||||
"jest-serializer-html": "^7.1.0",
|
||||
"less": "^4.1.2",
|
||||
"markdown-it": "^12.2.0",
|
||||
"markdown-it-anchor": "^8.4.1",
|
||||
"less": "^4.1.3",
|
||||
"markdown-it": "^12.3.2",
|
||||
"markdown-it-anchor": "^8.6.4",
|
||||
"nano-staged": "^0.8.0",
|
||||
"nanospinner": "^1.1.0",
|
||||
"picocolors": "^1.0.0",
|
||||
"postcss": "^8.3.11",
|
||||
"postcss-load-config": "^3.1.0",
|
||||
"prettier": "^2.5.0",
|
||||
"release-it": "^15.1.1",
|
||||
"transliteration": "^2.2.0",
|
||||
"typescript": "^4.7.4",
|
||||
"vite": "^3.0.0",
|
||||
"vite-plugin-html": "^2.1.1",
|
||||
"vite-plugin-md": "^0.11.4",
|
||||
"vue-router": "^4.0.12"
|
||||
"postcss": "^8.4.16",
|
||||
"postcss-load-config": "^3.1.4",
|
||||
"prettier": "^2.7.1",
|
||||
"release-it": "^15.4.1",
|
||||
"transliteration": "^2.3.5",
|
||||
"typescript": "^4.8.2",
|
||||
"vite": "^3.0.9",
|
||||
"vite-plugin-html": "^2.1.2",
|
||||
"vite-plugin-md": "^0.11.9",
|
||||
"vue-router": "^4.1.5"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -87,6 +87,7 @@ export default {
|
||||
padding: 24px;
|
||||
background-color: var(--van-doc-background-2);
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
overflow: auto;
|
||||
|
||||
> pre code {
|
||||
position: relative;
|
||||
|
@ -20,17 +20,17 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.3",
|
||||
"@typescript-eslint/parser": "^5.30.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||
"@typescript-eslint/parser": "^5.36.1",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-vue": "^9.1.1"
|
||||
"eslint-plugin-vue": "^9.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"enhanced-resolve": "^5.10.0",
|
||||
"eslint": "^8.19.0",
|
||||
"typescript": "^4.7.4"
|
||||
"eslint": "^8.23.0",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^7.32.0 || ^8.2.0"
|
||||
|
@ -23,7 +23,7 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"release-it": "^15.1.1"
|
||||
"release-it": "^15.4.1"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -37,12 +37,12 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.9.2"
|
||||
"@popperjs/core": "^2.11.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.14.29",
|
||||
"release-it": "^15.1.1",
|
||||
"typescript": "^4.7.4"
|
||||
"esbuild": "^0.14.54",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -37,10 +37,10 @@
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.14.29",
|
||||
"release-it": "^15.1.1",
|
||||
"typescript": "^4.7.4",
|
||||
"vue": "^3.2.27"
|
||||
"esbuild": "^0.14.54",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2",
|
||||
"vue": "^3.2.38"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -93,9 +93,9 @@ pnpm add vant
|
||||
|
||||
## 引入组件
|
||||
|
||||
### 方法一. 基础用法
|
||||
### 方法一. 常规用法
|
||||
|
||||
下面是使用 Vant 组件的基础用法示例:
|
||||
下面是使用 Vant 组件的用法示例:
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
@ -110,15 +110,15 @@ const app = createApp();
|
||||
app.use(Button);
|
||||
```
|
||||
|
||||
Vant 支持多种组件注册方式,除了在 app 上全局注册组件,你也可以选择其他的方式,详见 [组件注册](#/zh-CN/advanced-usage#zu-jian-zhu-ce) 章节。
|
||||
Vant 支持多种组件注册方式,除了在 app 上全局注册组件,你也可以选择其他的方式,比如局部注册,详见 [组件注册](#/zh-CN/advanced-usage#zu-jian-zhu-ce) 章节。
|
||||
|
||||
> 提示:Vant 默认支持 Tree Shaking,因此你不需要配置任何插件,通过 Tree Shaking 即可移除不需要的 JS 代码,但 CSS 样式无法通过这种方式优化,如果需要按需引入 CSS 样式,请参考下面的方法二。
|
||||
|
||||
### 方法二. 按需引入组件
|
||||
### 方法二. 按需引入组件样式
|
||||
|
||||
在基于 `vite`、`webpack` 或 `vue-cli` 的项目中使用 Vant 时,可以使用 [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 插件,它可以自动引入组件,并按需引入组件的样式。
|
||||
|
||||
相比于基础用法,这种方式可以按需引入组件的 CSS 样式,从而减少一部分代码体积。
|
||||
相比于常规用法,这种方式可以按需引入组件的 CSS 样式,从而减少一部分代码体积,但使用起来会变得繁琐一些。如果业务对 CSS 的体积要求不是特别极致,我们推荐使用更简便的常规用法。
|
||||
|
||||
#### 1. 安装插件
|
||||
|
||||
@ -216,6 +216,8 @@ import { showImagePreview } from 'vant';
|
||||
import 'vant/es/image-preview/style';
|
||||
```
|
||||
|
||||
你可以在项目的入口文件或公共模块中引入以上组件的样式,这样在业务代码中使用组件时,便不再需要重复引入样式了。
|
||||
|
||||
> 提示:在单个项目中不应该同时使用「全量引入」和「按需引入」,否则会导致代码重复、样式错乱等问题。
|
||||
|
||||
## 在框架中使用
|
||||
@ -238,3 +240,34 @@ export default defineNuxtConfig({
|
||||
|
||||
- [nuxt/framework#6761](https://github.com/nuxt/framework/issues/6761)
|
||||
- [nuxt/framework#4084](https://github.com/nuxt/framework/issues/4084)
|
||||
|
||||
## 迁移提示
|
||||
|
||||
### 移除 babel-plugin-import
|
||||
|
||||
从 Vant 4.0 版本开始,将不再支持 `babel-plugin-import`,请移除项目中依赖的 `babel-plugin-import` 插件。
|
||||
|
||||
只需要删除 `babel.config.js` 中的以下代码即可:
|
||||
|
||||
```diff
|
||||
module.exports = {
|
||||
plugins: [
|
||||
- ['import', {
|
||||
- libraryName: 'vant',
|
||||
- libraryDirectory: 'es',
|
||||
- style: true
|
||||
- }, 'vant']
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
#### 收益
|
||||
|
||||
移除 `babel-plugin-import` 有以下收益:
|
||||
|
||||
- 不再强依赖 babel,项目可以使用 esbuild、swc 等更高效的编译工具,大幅度提升编译效率。
|
||||
- 不再受到 `babel-plugin-import` 的 import 写法限制,可以从 vant 中导入除了组件以外的其他内容,比如 Vant 4 中新增的 `showToast` 等方法:
|
||||
|
||||
```ts
|
||||
import { showToast, showDialog } from 'vant';
|
||||
```
|
||||
|
@ -55,15 +55,15 @@
|
||||
"vue": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16",
|
||||
"@types/node": "^16.11.56",
|
||||
"@vant/area-data": "workspace:*",
|
||||
"@vant/cli": "workspace:*",
|
||||
"@vant/eslint-config": "workspace:*",
|
||||
"@vue/runtime-core": "^3.2.27",
|
||||
"@vue/test-utils": "^2.0.1",
|
||||
"typescript": "^4.7.4",
|
||||
"vue": "^3.2.27",
|
||||
"vue-router": "^4.0.12"
|
||||
"@vue/runtime-core": "^3.2.38",
|
||||
"@vue/test-utils": "^2.0.2",
|
||||
"typescript": "^4.8.2",
|
||||
"vue": "^3.2.38",
|
||||
"vue-router": "^4.1.5"
|
||||
},
|
||||
"sideEffects": [
|
||||
"es/**/style/*",
|
||||
|
@ -23,8 +23,8 @@ test('should trigger onClose option correctly', async () => {
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
expect(onClose).toHaveBeenCalledWith({
|
||||
index: 0,
|
||||
url: images[0],
|
||||
index: 1,
|
||||
url: images[1],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -221,13 +221,13 @@ export default defineComponent({
|
||||
const scrollParentRect = useRect(scrollParent);
|
||||
const { offsetHeight } = document.documentElement;
|
||||
|
||||
match.$el.scrollIntoView();
|
||||
|
||||
if (scrollTop === offsetHeight - scrollParentRect.height) {
|
||||
onScroll();
|
||||
return;
|
||||
}
|
||||
|
||||
match.$el.scrollIntoView();
|
||||
|
||||
if (props.sticky && props.stickyOffsetTop) {
|
||||
setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
|
||||
}
|
||||
|
@ -29,7 +29,10 @@ function genBem(name: string, mods?: Mods): string {
|
||||
}
|
||||
|
||||
if (Array.isArray(mods)) {
|
||||
return mods.reduce<string>((ret, item) => ret + genBem(name, item), '');
|
||||
return (mods as Mod[]).reduce<string>(
|
||||
(ret, item) => ret + genBem(name, item),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
return Object.keys(mods).reduce(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { App } from 'vue';
|
||||
import { camelize } from './format';
|
||||
import type { App, Component } from 'vue';
|
||||
|
||||
// https://github.com/vant-ui/vant/issues/8302
|
||||
type EventShim = {
|
||||
@ -14,11 +14,13 @@ export type WithInstall<T> = T & {
|
||||
install(app: App): void;
|
||||
} & EventShim;
|
||||
|
||||
export function withInstall<T>(options: T) {
|
||||
export function withInstall<T extends Component>(options: T) {
|
||||
(options as Record<string, unknown>).install = (app: App) => {
|
||||
const { name } = options as unknown as { name: string };
|
||||
const { name } = options;
|
||||
if (name) {
|
||||
app.component(name, options);
|
||||
app.component(camelize(`-${name}`), options);
|
||||
}
|
||||
};
|
||||
|
||||
return options as WithInstall<T>;
|
||||
|
1528
pnpm-lock.yaml
generated
1528
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user