mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
Merge branch 'dev' into next
This commit is contained in:
commit
e63f471c77
@ -1,3 +1,5 @@
|
||||
你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。
|
||||
注意:gitee 中为 vant 的镜像仓库,不进行 issue 处理。
|
||||
|
||||
http://vant-contrib.gitee.io/vant-issue-generater
|
||||
请移步 GitHub issues 进行反馈:
|
||||
|
||||
https://github.com/youzan/vant/issues
|
||||
|
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
@ -1,7 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: monthly
|
||||
open-pull-requests-limit: 20
|
25
README.md
25
README.md
@ -36,6 +36,7 @@
|
||||
- 🍭 Support Vue 2 & Vue 3
|
||||
- 🍭 Support Tree Shaking
|
||||
- 🍭 Support Custom Theme
|
||||
- 🍭 Support Accessibility (still improving)
|
||||
- 🍭 Support i18n
|
||||
- 🌍 Support SSR
|
||||
|
||||
@ -74,10 +75,6 @@ app.use(Button);
|
||||
|
||||
See more in [Quickstart](https://youzan.github.io/vant#/en-US/quickstart).
|
||||
|
||||
## Contribution
|
||||
|
||||
Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) before making a pull request.
|
||||
|
||||
## Browser Support
|
||||
|
||||
Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
|
||||
@ -117,6 +114,26 @@ You can scan the following QR code to access the demo:
|
||||
|
||||
<img src="https://img.yzcdn.cn/vant/preview_qrcode_20180528.png" width="220" height="220" >
|
||||
|
||||
## Core Team
|
||||
|
||||
Core contributors of Vant and Vant Weapp:
|
||||
|
||||
| [](https://github.com/chenjiahan/) | [](https://github.com/cookfront/) | [](https://github.com/w91/) | [](https://github.com/pangxie1991/) | [](https://github.com/rex-zsd/) | [](https://github.com/nemo-shen/) | [](https://github.com/Lindysen/) | [](https://github.com/JakeLaoyu/) |
|
||||
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
|
||||
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
|
||||
|
||||
## All Contributors
|
||||
|
||||
Thanks to the following friends for their contributions to Vant:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors">
|
||||
</a>
|
||||
|
||||
## Contribution Guide
|
||||
|
||||
Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) before making a pull request.
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](https://en.wikipedia.org/wiki/MIT_License)
|
||||
|
@ -40,6 +40,7 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源
|
||||
- 🍭 支持 Vue 2、Vue 3 和微信小程序
|
||||
- 🍭 支持主题定制,内置 700+ 个主题变量
|
||||
- 🍭 支持按需引入和 Tree Shaking
|
||||
- 🍭 支持无障碍访问(持续改进中)
|
||||
- 🍭 支持服务器端渲染
|
||||
- 🌍 支持国际化和语言包定制
|
||||
|
||||
@ -78,12 +79,6 @@ app.use(Button);
|
||||
|
||||
vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手](https://vant-contrib.gitee.io/vant#/zh-CN/quickstart).
|
||||
|
||||
## 贡献代码
|
||||
|
||||
修改代码请阅读我们的 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。
|
||||
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。
|
||||
|
||||
## 浏览器支持
|
||||
|
||||
Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。
|
||||
@ -127,6 +122,28 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
|
||||
<img src="https://img.yzcdn.cn/vant/preview_qrcode_20180528.png" width="220" height="220" >
|
||||
|
||||
## 核心团队
|
||||
|
||||
以下是 Vant 和 Vant Weapp 的核心贡献者们:
|
||||
|
||||
| [](https://github.com/chenjiahan/) | [](https://github.com/cookfront/) | [](https://github.com/w91/) | [](https://github.com/pangxie1991/) | [](https://github.com/rex-zsd/) | [](https://github.com/nemo-shen/) | [](https://github.com/Lindysen/) | [](https://github.com/JakeLaoyu/) |
|
||||
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
|
||||
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
|
||||
|
||||
## 贡献者们
|
||||
|
||||
感谢以下小伙伴们为 Vant 发展做出的贡献:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors">
|
||||
</a>
|
||||
|
||||
## 贡献指南
|
||||
|
||||
修改代码请阅读我们的 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。
|
||||
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。
|
||||
|
||||
## 开源协议
|
||||
|
||||
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。
|
||||
|
@ -22,8 +22,8 @@
|
||||
"@vant/stylelint-config": "workspace:*",
|
||||
"eslint": "^8.2.0",
|
||||
"husky": "^7.0.4",
|
||||
"lint-staged": "^11.2.6",
|
||||
"prettier": "^2.4.1",
|
||||
"lint-staged": "^12.1.2",
|
||||
"prettier": "^2.5.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"stylelint": "^13.13.1"
|
||||
}
|
||||
|
@ -8,14 +8,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsc --watch",
|
||||
"build": "tsc",
|
||||
"build": "rimraf ./lib && tsc",
|
||||
"release": "pnpm build & release-it",
|
||||
"prepare": "pnpm build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"generators"
|
||||
@ -26,13 +22,19 @@
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/create-vant-cli-app"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/inquirer": "^8.1.3",
|
||||
"release-it": "^14.11.6",
|
||||
"typescript": "4.x"
|
||||
"typescript": "~4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
|
@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"]
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -4,15 +4,21 @@
|
||||
"description": "Vant 省市区数据",
|
||||
"main": "./lib/index.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "rimraf ./lib && tsc",
|
||||
"release": "pnpm build && npm publish",
|
||||
"prepare": "pnpm build"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"release": "pnpm build && npm publish",
|
||||
"prepare": "pnpm build"
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-area-data"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant"
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"outDir": "./lib",
|
||||
"module": "ES2015",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"]
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
# 更新日志
|
||||
|
||||
## v4.0.0-rc.4
|
||||
|
||||
- 新增 CommonJS 格式的构建产物,分别为 `lib/[name].cjs.js` 和 `lib/[name].cjs.min.js`
|
||||
- 现在 ESModule 和 CommonJS 格式的产物会自动对外部依赖进行 external 处理
|
||||
- 修复 Windows 路径兼容问题
|
||||
|
||||
## v4.0.0-rc.3
|
||||
|
||||
### 不兼容更新
|
||||
@ -286,7 +292,7 @@ yarn add sass
|
||||
|
||||
`2020-12-01`
|
||||
|
||||
- 升级 docsearch 3,优化搜索框样式
|
||||
- 升级 docsearch 3,优化搜索框样式
|
||||
|
||||
## v3.0.0
|
||||
|
||||
@ -469,7 +475,7 @@ yarn add sass
|
||||
|
||||
`2020-01-15`
|
||||
|
||||
- 优化 help 命令
|
||||
- 优化 help 命令
|
||||
- 优化控制台输出信息
|
||||
|
||||
### v2.1.6
|
||||
|
@ -1,13 +1,15 @@
|
||||
# 配置指南
|
||||
|
||||
- [配置指南](#)
|
||||
- [配置指南](#----)
|
||||
- [vant.config.mjs](#vantconfigmjs)
|
||||
- [name](#name)
|
||||
- [build.css](#buildcss)
|
||||
- [build.css.base](#buildcssbase)
|
||||
- [build.css.preprocessor](#buildcsspreprocessor)
|
||||
- [build.site.publicPath](#buildsitepublicpath)
|
||||
- [build.srcDir](#buildsrcdir)
|
||||
- [build.namedExport](#buildnamedexport)
|
||||
- [build.configureVite](#buildconfigurevite)
|
||||
- [build.packageManager](#buildpackagemanager)
|
||||
- [site.title](#sitetitle)
|
||||
- [site.logo](#sitelogo)
|
||||
- [site.description](#sitedescription)
|
||||
@ -18,11 +20,11 @@
|
||||
- [site.hideSimulator](#sitehidesimulator)
|
||||
- [site.simulator.url](#sitesimulatorurl)
|
||||
- [site.htmlMeta](#sitehtmlmeta)
|
||||
- [site.enableVConsole](#siteenablevconsole)
|
||||
- [Babel](#babel)
|
||||
- [默认配置](#-1)
|
||||
- [依赖](#-2)
|
||||
- [默认配置](#----)
|
||||
- [Postcss](#postcss)
|
||||
- [默认配置](#-3)
|
||||
- [默认配置](#-----1)
|
||||
- [browserslist](#browserslist)
|
||||
|
||||
## vant.config.mjs
|
||||
@ -77,14 +79,33 @@ export default {
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
组件库名称,建议使用中划线分割,如`demo-ui`。
|
||||
组件库名称,建议使用中划线分割,如 `demo-ui`。
|
||||
|
||||
### build.css
|
||||
### build.css.base
|
||||
|
||||
- Type: `object`
|
||||
- Default: `{ preprocessor: 'less' }`
|
||||
- Type: `string`
|
||||
- Default: `'style/base.less'`
|
||||
|
||||
CSS 预处理器配置,目前支持`less`和`sass`两种预处理器,默认使用`less`。
|
||||
全局样式文件的路径,可以为相对路径或绝对路径。
|
||||
|
||||
相对路径基于 `src` 目录计算。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
css: {
|
||||
base: 'style/global.scss',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.css.preprocessor
|
||||
|
||||
- Type: `string`
|
||||
- Default: `'less'`
|
||||
|
||||
CSS 预处理器配置,目前支持 `less` 和 `sass` 两种预处理器,默认使用 `less`。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/cli",
|
||||
"version": "4.0.0-rc.3",
|
||||
"version": "4.0.0-rc.4",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@ -10,13 +10,9 @@
|
||||
"engines": {
|
||||
"node": "^14.16.0 || >=16.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsc --watch",
|
||||
"build": "tsc",
|
||||
"build": "rimraf ./lib && tsc",
|
||||
"release": "pnpm build & release-it",
|
||||
"prepare": "pnpm build"
|
||||
},
|
||||
@ -31,6 +27,16 @@
|
||||
"keywords": [
|
||||
"vant"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-cli"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
@ -42,12 +48,12 @@
|
||||
"vue": "^3.2.20"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/jest": "^27.0.3",
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/preset-env": "^7.16.0",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@docsearch/css": "3.0.0-alpha.41",
|
||||
"@docsearch/js": "3.0.0-alpha.41",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@vant/eslint-config": "^3.3.2",
|
||||
"@vant/markdown-vetur": "^2.2.0",
|
||||
"@vant/stylelint-config": "^1.4.2",
|
||||
@ -74,19 +80,19 @@
|
||||
"jest-canvas-mock": "^2.3.1",
|
||||
"jest-serializer-html": "^7.1.0",
|
||||
"less": "^4.1.2",
|
||||
"lint-staged": "^11.2.6",
|
||||
"lint-staged": "^12.1.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"markdown-it": "^12.2.0",
|
||||
"markdown-it-anchor": "^8.4.1",
|
||||
"ora": "^6.0.1",
|
||||
"postcss": "^8.3.11",
|
||||
"postcss-load-config": "^3.1.0",
|
||||
"prettier": "^2.4.1",
|
||||
"prettier": "^2.5.0",
|
||||
"release-it": "^14.11.6",
|
||||
"stylelint": "^13.0.0",
|
||||
"transliteration": "^2.2.0",
|
||||
"ts-jest": "^27.0.7",
|
||||
"typescript": "^4.4.4",
|
||||
"typescript": "^4.5.2",
|
||||
"vite": "^2.6.13",
|
||||
"vite-plugin-html": "^2.1.1",
|
||||
"vite-plugin-md": "^0.11.4",
|
||||
|
@ -170,6 +170,10 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
> ul {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
> ul li,
|
||||
> ol li {
|
||||
position: relative;
|
||||
|
@ -8,7 +8,7 @@ import { installDependencies } from '../common/manager.js';
|
||||
import { compileSfc } from '../compiler/compile-sfc.js';
|
||||
import { compileStyle } from '../compiler/compile-style.js';
|
||||
import { compileScript } from '../compiler/compile-script.js';
|
||||
import { compilePackage } from '../compiler/compile-package.js';
|
||||
import { compileBundles } from '../compiler/compile-bundles.js';
|
||||
import { genPackageEntry } from '../compiler/gen-package-entry.js';
|
||||
import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js';
|
||||
import { genComponentStyle } from '../compiler/gen-component-style.js';
|
||||
@ -133,8 +133,7 @@ async function buildPackageStyleEntry() {
|
||||
|
||||
async function buildBundledOutputs() {
|
||||
setModuleEnv('esmodule');
|
||||
await compilePackage(false);
|
||||
await compilePackage(true);
|
||||
await compileBundles();
|
||||
genVeturConfig();
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,9 @@ import {
|
||||
JEST_CONFIG_FILE,
|
||||
PACKAGE_ENTRY_FILE,
|
||||
} from '../common/constant.js';
|
||||
import type { Config } from '@jest/types';
|
||||
|
||||
export function test(command: any) {
|
||||
export function test(command: Config.Argv) {
|
||||
setNodeEnv('test');
|
||||
|
||||
genPackageEntry({
|
||||
@ -26,7 +27,7 @@ export function test(command: any) {
|
||||
// make jest tests faster
|
||||
// see: https://ivantanev.com/make-jest-faster/
|
||||
maxWorkers: '50%',
|
||||
} as any;
|
||||
} as Config.Argv;
|
||||
|
||||
jest
|
||||
.runCLI(config, [ROOT])
|
||||
|
68
packages/vant-cli/src/compiler/compile-bundles.ts
Normal file
68
packages/vant-cli/src/compiler/compile-bundles.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import fse from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { build } from 'vite';
|
||||
import { getPackageJson, getVantConfig, LIB_DIR } from '../common/constant.js';
|
||||
import { mergeCustomViteConfig } from '../common/index.js';
|
||||
import { getViteConfigForPackage } from '../config/vite.package.js';
|
||||
|
||||
// generate entry file for nuxt
|
||||
async function genEntryForSSR() {
|
||||
const { name } = getVantConfig();
|
||||
const cjsPath = join(LIB_DIR, 'ssr.js');
|
||||
const mjsPath = join(LIB_DIR, 'ssr.mjs');
|
||||
|
||||
const cjsContent = `'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./${name}.cjs.min.js');
|
||||
} else {
|
||||
module.exports = require('./${name}.cjs.js');
|
||||
};
|
||||
`;
|
||||
|
||||
const mjsContent = `export * from './index.js';\n`;
|
||||
|
||||
return Promise.all([
|
||||
fse.outputFile(cjsPath, cjsContent),
|
||||
fse.outputFile(mjsPath, mjsContent),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function compileBundles() {
|
||||
const dependencies = getPackageJson().dependencies || {};
|
||||
const externals = Object.keys(dependencies);
|
||||
|
||||
const configs = [
|
||||
// umd bundle
|
||||
getViteConfigForPackage({
|
||||
minify: false,
|
||||
formats: ['umd'],
|
||||
external: ['vue'],
|
||||
}),
|
||||
// umd bundle (minified)
|
||||
getViteConfigForPackage({
|
||||
minify: true,
|
||||
formats: ['umd'],
|
||||
external: ['vue'],
|
||||
}),
|
||||
// esm/cjs bundle
|
||||
getViteConfigForPackage({
|
||||
minify: false,
|
||||
formats: ['es', 'cjs'],
|
||||
external: ['vue', ...externals],
|
||||
}),
|
||||
// esm/cjs bundle (minified)
|
||||
// vite will not minify es bundle
|
||||
// see: https://github.com/vuejs/vue-next/issues/2860
|
||||
getViteConfigForPackage({
|
||||
minify: true,
|
||||
formats: ['es', 'cjs'],
|
||||
external: ['vue', ...externals],
|
||||
}),
|
||||
];
|
||||
|
||||
await Promise.all(
|
||||
configs.map((config) => build(mergeCustomViteConfig(config)))
|
||||
);
|
||||
await genEntryForSSR();
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { build } from 'vite';
|
||||
import { mergeCustomViteConfig } from '../common/index.js';
|
||||
import { getViteConfigForPackage } from '../config/vite.package.js';
|
||||
|
||||
export async function compilePackage(
|
||||
minify: boolean
|
||||
): ReturnType<typeof build> {
|
||||
const config = mergeCustomViteConfig(getViteConfigForPackage(minify));
|
||||
return build(config);
|
||||
}
|
@ -1,9 +1,17 @@
|
||||
import { join } from 'path';
|
||||
import type { InlineConfig } from 'vite';
|
||||
import { setBuildTarget } from '../common/index.js';
|
||||
import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant.js';
|
||||
import type { InlineConfig, LibraryFormats } from 'vite';
|
||||
|
||||
export function getViteConfigForPackage(minify: boolean): InlineConfig {
|
||||
export function getViteConfigForPackage({
|
||||
minify,
|
||||
formats,
|
||||
external,
|
||||
}: {
|
||||
minify: boolean;
|
||||
formats: LibraryFormats[];
|
||||
external: string[];
|
||||
}): InlineConfig {
|
||||
setBuildTarget('package');
|
||||
|
||||
const { name } = getVantConfig();
|
||||
@ -17,6 +25,7 @@ export function getViteConfigForPackage(minify: boolean): InlineConfig {
|
||||
lib: {
|
||||
name,
|
||||
entry: join(ES_DIR, 'index.js'),
|
||||
formats,
|
||||
fileName: (format: string) => {
|
||||
const suffix = format === 'umd' ? '' : `.${format}`;
|
||||
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
|
||||
@ -25,7 +34,7 @@ export function getViteConfigForPackage(minify: boolean): InlineConfig {
|
||||
// terser has better compression than esbuild
|
||||
minify: minify ? 'terser' : false,
|
||||
rollupOptions: {
|
||||
external: ['vue'],
|
||||
external,
|
||||
output: {
|
||||
dir: LIB_DIR,
|
||||
exports: 'named',
|
||||
|
@ -1,14 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"outDir": "./lib",
|
||||
"module": "ESNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution":"Node",
|
||||
"lib": ["esnext", "dom"]
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -1,14 +1,20 @@
|
||||
{
|
||||
"name": "@vant/eslint-config",
|
||||
"version": "3.3.2",
|
||||
"version": "3.4.0",
|
||||
"description": "eslint config of vant",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-eslint-config"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-eslint-config",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
||||
"@typescript-eslint/parser": "5.3.1",
|
||||
@ -19,6 +25,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.0.0",
|
||||
"typescript": "4.x"
|
||||
"typescript": "~4.5.2"
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,21 @@
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"release": "release-it"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"scripts": {
|
||||
"release": "release-it"
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-icons"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-icons",
|
||||
"devDependencies": {
|
||||
"release-it": "^14.11.6"
|
||||
},
|
||||
|
@ -7,8 +7,14 @@
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-markdown-loader"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-markdown-loader",
|
||||
"dependencies": {
|
||||
"front-matter": "^4.0.2",
|
||||
"highlight.js": "^10.7.1",
|
||||
|
@ -3,22 +3,27 @@
|
||||
"version": "2.2.0",
|
||||
"description": "simple parse markdown to vue component description for vetur auto-completion",
|
||||
"main": "lib/index.js",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-markdown-vetur",
|
||||
"author": "zhangshuai",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "tsc --watch",
|
||||
"build": "tsc",
|
||||
"build": "rimraf ./lib && tsc",
|
||||
"release": "pnpm build && npm publish",
|
||||
"prepare": "pnpm build"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-markdown-vetur"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "zhangshuai",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fast-glob": "^3.2.2",
|
||||
"fs-extra": "^10.0.0"
|
||||
|
@ -1,13 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"]
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
1
packages/vant-popperjs/build.js
Normal file
1
packages/vant-popperjs/build.js
Normal file
@ -0,0 +1 @@
|
||||
require('../vant-use/build');
|
@ -2,8 +2,8 @@
|
||||
"name": "@vant/popperjs",
|
||||
"version": "1.1.0",
|
||||
"description": "Pre-compiled popperjs core",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
@ -15,24 +15,28 @@
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf ./dist",
|
||||
"dev": "rollup --config rollup.config.js --watch",
|
||||
"dev": "node ./build.js -w",
|
||||
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"build:bundle": "node ./build.js",
|
||||
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
|
||||
"release": "pnpm build && release-it",
|
||||
"prepare": "pnpm build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-markdown-loader"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-popperjs",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.9.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "4.x",
|
||||
"rollup": "^2.33.3",
|
||||
"rollup-plugin-esbuild": "^4.6.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.0",
|
||||
"release-it": "^14.2.2"
|
||||
"esbuild": "^0.13.15",
|
||||
"release-it": "^14.2.2",
|
||||
"typescript": "~4.5.2"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -1,18 +0,0 @@
|
||||
import path from 'path';
|
||||
import esbuild from 'rollup-plugin-esbuild';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
|
||||
export default {
|
||||
input: path.join(__dirname, 'src', 'index.ts'),
|
||||
output: [
|
||||
{
|
||||
dir: 'dist/cjs',
|
||||
format: 'cjs',
|
||||
},
|
||||
{
|
||||
dir: 'dist/esm',
|
||||
format: 'esm',
|
||||
},
|
||||
],
|
||||
plugins: [esbuild(), nodeResolve()],
|
||||
};
|
@ -1,12 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2015",
|
||||
"outDir": "./dist",
|
||||
"module": "ESNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "Node",
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -7,8 +7,14 @@
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-stylelint-config"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-stylelint-config",
|
||||
"dependencies": {
|
||||
"stylelint-config-prettier": "^8.0.1",
|
||||
"stylelint-config-standard": "^22.0.0"
|
||||
|
@ -6,6 +6,12 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator"
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-touch-emulator"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
20
packages/vant-use/build.js
Normal file
20
packages/vant-use/build.js
Normal file
@ -0,0 +1,20 @@
|
||||
const { build } = require('esbuild');
|
||||
|
||||
function bundleBundle(format) {
|
||||
const outfile = `dist/index.${format}.js`;
|
||||
const finish = () => console.log('Build finished:', outfile);
|
||||
const onRebuild = (error) => (error ? console.log(error) : finish());
|
||||
|
||||
build({
|
||||
watch: process.argv.includes('-w') && { onRebuild },
|
||||
format,
|
||||
bundle: true,
|
||||
target: ['chrome53'],
|
||||
outfile,
|
||||
external: ['vue'],
|
||||
entryPoints: ['./src/index.ts'],
|
||||
}).then(finish);
|
||||
}
|
||||
|
||||
bundleBundle('esm');
|
||||
bundleBundle('cjs');
|
@ -2,8 +2,8 @@
|
||||
"name": "@vant/use",
|
||||
"version": "1.3.4",
|
||||
"description": "Vant Composition API",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
@ -11,9 +11,9 @@
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf ./dist",
|
||||
"dev": "rollup --config rollup.config.js --watch",
|
||||
"dev": "node ./build.js -w",
|
||||
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"build:bundle": "node ./build.js",
|
||||
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
|
||||
"release": "pnpm build && release-it",
|
||||
"prepare": "pnpm build"
|
||||
@ -22,13 +22,18 @@
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant-use"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/youzan/vant/tree/dev/packages/vant-use",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.13.15",
|
||||
"release-it": "^14.0.2",
|
||||
"typescript": "4.x",
|
||||
"rollup": "^2.33.3",
|
||||
"rollup-plugin-esbuild": "^4.6.0",
|
||||
"typescript": "~4.5.2",
|
||||
"vue": "^3.2.20"
|
||||
},
|
||||
"release-it": {
|
||||
|
@ -1,18 +0,0 @@
|
||||
import path from 'path';
|
||||
import esbuild from 'rollup-plugin-esbuild';
|
||||
|
||||
export default {
|
||||
input: path.join(__dirname, 'src', 'index.ts'),
|
||||
output: [
|
||||
{
|
||||
dir: 'dist/cjs',
|
||||
format: 'cjs',
|
||||
},
|
||||
{
|
||||
dir: 'dist/esm',
|
||||
format: 'esm',
|
||||
},
|
||||
],
|
||||
external: ['vue'],
|
||||
plugins: [esbuild()],
|
||||
};
|
@ -1,12 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2015",
|
||||
"outDir": "./dist",
|
||||
"module": "ESNext",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "Node",
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -16,22 +16,125 @@ Vant follows [Semantic Versioning 2.0.0](https://semver.org/lang/zh-CN/).
|
||||
|
||||
## Details
|
||||
|
||||
### [v3.3.6](https://github.com/compare/v3.3.5...v3.3.6)
|
||||
|
||||
`2021-12-05`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- fix ssr.js require path [#9999](https://github.com/youzan/vant/issues/9999)
|
||||
|
||||
### [v3.3.5](https://github.com/compare/v3.3.4...v3.3.5)
|
||||
|
||||
`2021-12-02`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- fix exports field break SSR [#9988](https://github.com/youzan/vant/issues/9988)
|
||||
- fix exports field break unplugin-vue-components [#9985](https://github.com/youzan/vant/issues/9985)
|
||||
|
||||
### [v3.3.4](https://github.com/compare/v3.3.3...v3.3.4)
|
||||
|
||||
`2021-12-01`
|
||||
|
||||
- fix `lib/ssr.js` not exist
|
||||
|
||||
### [v3.3.3](https://github.com/compare/v3.3.2...v3.3.3)
|
||||
|
||||
`2021-11-30`
|
||||
|
||||
**Feature**
|
||||
|
||||
- Support nuxt3 [#9970](https://github.com/youzan/vant/issues/9970)
|
||||
- Locale: add pt-BR locale [#9959](https://github.com/youzan/vant/issues/9959)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Swipe: fix incorrect border radius in iOS safari [#9958](https://github.com/youzan/vant/issues/9958)
|
||||
- Uploader: fix preview is slow when sum of images size be bigger [#9961](https://github.com/youzan/vant/issues/9961)
|
||||
|
||||
### [v3.3.2](https://github.com/compare/v3.3.1...v3.3.2)
|
||||
|
||||
`2021-11-28`
|
||||
|
||||
**Feature**
|
||||
|
||||
- add exports field and use bundled output by default [#9952](https://github.com/youzan/vant/issues/9952)
|
||||
- Tabbar: support highlighted with child route [#9926](https://github.com/youzan/vant/issues/9926)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Calendar: auto selected to max range when show-confirm is false [#9948](https://github.com/youzan/vant/issues/9948)
|
||||
- Calendar: should scroll to current date instead of current month [#9949](https://github.com/youzan/vant/issues/9949)
|
||||
- Swipe: should prevent touchmove event when swiping [#9920](https://github.com/youzan/vant/issues/9920)
|
||||
- Tabs: rename wrapper class to `van-tab__panel-wrapper` [#9951](https://github.com/youzan/vant/issues/9951)
|
||||
|
||||
### [v3.3.1](https://github.com/compare/v3.3.0...v3.3.1)
|
||||
|
||||
`2021-11-23`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- AddressEdit: should not emit save event when validation failed [#9917](https://github.com/youzan/vant/issues/9917)
|
||||
|
||||
### [v3.3.0](https://github.com/compare/v3.2.8...v3.3.0)
|
||||
|
||||
`2021-11-19`
|
||||
|
||||
**Accessibility**
|
||||
|
||||
- Cascader: add role, aria and tabindex [#9886](https://github.com/youzan/vant/issues/9886)
|
||||
- CountDown: add timer role [#9906](https://github.com/youzan/vant/issues/9906)
|
||||
- DropdownMenu: add role, aria and tabindex [#9893](https://github.com/youzan/vant/issues/9893)
|
||||
- Field: add aria-labelledby [#9883](https://github.com/youzan/vant/issues/9883)
|
||||
- List: add role and tabindex [#9888](https://github.com/youzan/vant/issues/9888)
|
||||
- Pagination: refactor DOM to improve a11y [#9901](https://github.com/youzan/vant/issues/9901)
|
||||
- Popover: add tabindex and aria-disabled [#9889](https://github.com/youzan/vant/issues/9889)
|
||||
- Rate: improve a11y when disabled or readonly [#9881](https://github.com/youzan/vant/issues/9881)
|
||||
- Search: id prop add default value [#9884](https://github.com/youzan/vant/issues/9884)
|
||||
- Sidebar: add role, aria and tabindex [#9903](https://github.com/youzan/vant/issues/9903)
|
||||
- Slider: improve a11y when disabled or readonly [#9880](https://github.com/youzan/vant/issues/9880)
|
||||
- Stepper: add aria-disabled [#9877](https://github.com/youzan/vant/issues/9877)
|
||||
- Stepper: add group role [#9876](https://github.com/youzan/vant/issues/9876)
|
||||
- Switch: add tabindex [#9887](https://github.com/youzan/vant/issues/9887)
|
||||
- Tabbar: add role, aria and tabindex [#9895](https://github.com/youzan/vant/issues/9895)
|
||||
- Tabs: add aria-controls [#9882](https://github.com/youzan/vant/issues/9882)
|
||||
- Tabs: add aria-disabled [#9878](https://github.com/youzan/vant/issues/9878)
|
||||
- Tabs: add aria-orientation and tabindex [#9872](https://github.com/youzan/vant/issues/9872)
|
||||
- Uploader: add role, aria and tabindex [#9905](https://github.com/youzan/vant/issues/9905)
|
||||
- remove tabindex from disabled elements [#9879](https://github.com/youzan/vant/issues/9879)
|
||||
|
||||
**Feature**
|
||||
|
||||
- Popup: reduce unused listener [#9896](https://github.com/youzan/vant/issues/9896)
|
||||
- Field: expose sub-types of FieldRule [#9843](https://github.com/youzan/vant/issues/9843)
|
||||
- minify svg icons [#9869](https://github.com/youzan/vant/issues/9869)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Popover: useClickAway failed in SSR [#9899](https://github.com/youzan/vant/issues/9899)
|
||||
- CouponList: incorrect list height [#9874](https://github.com/youzan/vant/issues/9874)
|
||||
- Field: should not trigger validation after blurring readonly input [#9862](https://github.com/youzan/vant/issues/9862)
|
||||
- Switch: switch node inherit font-size [#9842](https://github.com/youzan/vant/issues/9842)
|
||||
- Tabbar: before-change not work in route mode [#9856](https://github.com/youzan/vant/issues/9856)
|
||||
- Tabs: rename panel class to `van-tab__panel` [#9885](https://github.com/youzan/vant/issues/9885)
|
||||
|
||||
### [v3.2.8](https://github.com/compare/v3.2.7...v3.2.8)
|
||||
|
||||
`2021-11-09`
|
||||
|
||||
**Feature**
|
||||
|
||||
- Cascader: add options-bottom slot [#9804](https://github.com/issues/9804)
|
||||
- Cascader: add options-bottom slot [#9804](https://github.com/youzan/vant/issues/9804)
|
||||
- SubmitBar: add SubmitBarTextAlign type [f95567](https://github.com/commit/f95567ade758d453f4acad8a40d8ae717035476a)
|
||||
- PasswordInput: add PasswordInputProps type [#9820](https://github.com/issues/9820)
|
||||
- PasswordInput: add PasswordInputProps type [#9820](https://github.com/youzan/vant/issues/9820)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- NavBar: fix NavBarProps spelling [#9818](https://github.com/issues/9818)
|
||||
- Progress: incorrect border-radius [#9826](https://github.com/issues/9826)
|
||||
- SubmitBar: fix missing SubmitBarProps export [#9819](https://github.com/issues/9819)
|
||||
- Tabs: should emit click-tab after before-change [#9805](https://github.com/issues/9805)
|
||||
- NavBar: fix NavBarProps spelling [#9818](https://github.com/youzan/vant/issues/9818)
|
||||
- Progress: incorrect border-radius [#9826](https://github.com/youzan/vant/issues/9826)
|
||||
- SubmitBar: fix missing SubmitBarProps export [#9819](https://github.com/youzan/vant/issues/9819)
|
||||
- Tabs: should emit click-tab after before-change [#9805](https://github.com/youzan/vant/issues/9805)
|
||||
|
||||
### [v3.2.7](https://github.com/youzan/vant/compare/v3.2.6...v3.2.7)
|
||||
|
||||
|
@ -16,22 +16,128 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
|
||||
|
||||
## 更新内容
|
||||
|
||||
### [v3.3.6](https://github.com/compare/v3.3.5...v3.3.6)
|
||||
|
||||
`2021-12-05`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- 修复 ssr.js 文件引用路径错误的问题 [#9999](https://github.com/youzan/vant/issues/9999)
|
||||
|
||||
### [v3.3.5](https://github.com/compare/v3.3.4...v3.3.5)
|
||||
|
||||
`2021-12-02`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- 修复 exports field 导致 SSR 无法正确引入的问题 [#9988](https://github.com/youzan/vant/issues/9988)
|
||||
- 修复 exports field 导致 unplugin-vue-components 引用报错的问题 [#9985](https://github.com/youzan/vant/issues/9985)
|
||||
|
||||
### [v3.3.4](https://github.com/compare/v3.3.3...v3.3.4)
|
||||
|
||||
`2021-12-01`
|
||||
|
||||
- 修复 `lib/ssr.js` 文件不存在导致 SSR 失败的问题
|
||||
|
||||
### [v3.3.3](https://github.com/compare/v3.3.2...v3.3.3)
|
||||
|
||||
`2021-11-30`
|
||||
|
||||
**Feature**
|
||||
|
||||
- 支持在 nuxt3 中使用 [#9970](https://github.com/youzan/vant/issues/9970)
|
||||
- Locale: 新增 pt-BR 葡萄牙语 (巴西) [#9959](https://github.com/youzan/vant/issues/9959)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Swipe: 修复 iOS 系统下圆角失效的问题 [#9958](https://github.com/youzan/vant/issues/9958)
|
||||
- Uploader: 修复图片预览卡顿的问题 [#9961](https://github.com/youzan/vant/issues/9961)
|
||||
|
||||
### [v3.3.2](https://github.com/compare/v3.3.1...v3.3.2)
|
||||
|
||||
`2021-11-28`
|
||||
|
||||
**Feature**
|
||||
|
||||
- 新增 `package.json` 中的 `exports` 字段 [#9952](https://github.com/issues/9952)
|
||||
- Tabbar: 支持在 route 模式下匹配子路由 [#9926](https://github.com/issues/9926)
|
||||
- Tabs: 将 `van-tab__pane-wrapper` 类重命名为 `van-tab__panel-wrapper` [#9951](https://github.com/issues/9951)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Calendar: 修复 show-confirm 为 false 时不会限制最大日期范围的问题 [#9948](https://github.com/issues/9948)
|
||||
- Calendar: 修复 `scrollToDate` 方法无法精确滚动到对应日期的问题 [#9949](https://github.com/issues/9949)
|
||||
- Swipe: 修复开始滑动时未阻止 touchmove 事件行为的问题 [#9920](https://github.com/issues/9920)
|
||||
|
||||
### [v3.3.1](https://github.com/compare/v3.3.0...v3.3.1)
|
||||
|
||||
`2021-11-23`
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- AddressEdit: 修复表单校验不通过时也会触发 save 事件的问题 [#9917](https://github.com/issues/9917)
|
||||
|
||||
### [v3.3.0](https://github.com/compare/v3.2.8...v3.3.0)
|
||||
|
||||
`2021-11-19`
|
||||
|
||||
**Accessibility**
|
||||
|
||||
改善以下组件的无障碍访问体验:
|
||||
|
||||
- Cascader: 增加 role="menu", tabindex, aria-checked, aria-disabled 属性 [#9886](https://github.com/youzan/vant/issues/9886)
|
||||
- CountDown: 增加 role="timer" 属性 [#9906](https://github.com/youzan/vant/issues/9906)
|
||||
- DropdownMenu: 增加 role="menu", tabindex, aria-labelledby 属性 [#9893](https://github.com/youzan/vant/issues/9893)
|
||||
- Field: 增加 aria-labelledby 属性 [#9883](https://github.com/youzan/vant/issues/9883)
|
||||
- List: 增加 role="button", tabindex 属性 [#9888](https://github.com/youzan/vant/issues/9888)
|
||||
- Pagination: 增加 role="navigation" 和 button 标签 [#9901](https://github.com/youzan/vant/issues/9901)
|
||||
- Popover: 增加 tabindex, aria-disabled 属性 [#9889](https://github.com/youzan/vant/issues/9889)
|
||||
- Rate: 增加 aria-disabled, aria-readonly 属性 [#9881](https://github.com/youzan/vant/issues/9881)
|
||||
- Search: 提供默认的 id 属性 属性 [#9884](https://github.com/youzan/vant/issues/9884)
|
||||
- Sidebar: 增加 role="tab", tabindex, aria-selected 属性 [#9903](https://github.com/youzan/vant/issues/9903)
|
||||
- Slider: 增加 aria-disabled, aria-readonly 属性 [#9880](https://github.com/youzan/vant/issues/9880)
|
||||
- Stepper: 增加 aria-disabled 属性 [#9877](https://github.com/youzan/vant/issues/9877)
|
||||
- Stepper: 增加 role="group" 属性 [#9876](https://github.com/youzan/vant/issues/9876)
|
||||
- Switch: 增加 tabindex 属性 [#9887](https://github.com/youzan/vant/issues/9887)
|
||||
- Tabbar: 增加 role="tab", tabindex, aria-selected 属性 [#9895](https://github.com/youzan/vant/issues/9895)
|
||||
- Tabs: 增加 aria-controls 属性 [#9882](https://github.com/youzan/vant/issues/9882)
|
||||
- Tabs: 增加 aria-disabled 属性 [#9878](https://github.com/youzan/vant/issues/9878)
|
||||
- Tabs: 增加 tabindex, aria-orientation 属性 [#9872](https://github.com/youzan/vant/issues/9872)
|
||||
- Uploader: 删除按钮增加 role="button", tabindex, aria-label 属性 [#9905](https://github.com/youzan/vant/issues/9905)
|
||||
- 移除禁用元素的 tabindex 属性 [#9879](https://github.com/youzan/vant/issues/9879)
|
||||
|
||||
**Feature**
|
||||
|
||||
- Popup: 移除多余的 click 事件监听 [#9896](https://github.com/youzan/vant/issues/9896)
|
||||
- Field: 导出 `FieldRuleValidator` 等多个类型定义 [#9843](https://github.com/youzan/vant/issues/9843)
|
||||
- Empty: 压缩 svg 图标 [#9869](https://github.com/youzan/vant/issues/9869)
|
||||
- NumberKeyboard: 压缩 svg 图标 [#9869](https://github.com/youzan/vant/issues/9869)
|
||||
- Tabs: 将 `van-tab__pane` 类重命名为 `van-tab__panel` [#9885](https://github.com/youzan/vant/issues/9885)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Popover: 修复 useClickAway 方法在 SSR 时报错的问题 [#9899](https://github.com/youzan/vant/issues/9899)
|
||||
- CouponList: 修复列表高度不正确的问题 [#9874](https://github.com/youzan/vant/issues/9874)
|
||||
- Field: 修复点击只读输入框会触发表单验证的问题 [#9862](https://github.com/youzan/vant/issues/9862)
|
||||
- Switch: 修复全局设置 font-size 时样式错误的问题 [#9842](https://github.com/youzan/vant/issues/9842)
|
||||
- Tabbar: 修复 route 模式下无法触发 before-change 属性的问题 [#9856](https://github.com/youzan/vant/issues/9856)
|
||||
|
||||
### [v3.2.8](https://github.com/compare/v3.2.7...v3.2.8)
|
||||
|
||||
`2021-11-09`
|
||||
|
||||
**Feature**
|
||||
|
||||
- Cascader: 新增 options-bottom 插槽 [#9804](https://github.com/issues/9804)
|
||||
- Cascader: 新增 options-bottom 插槽 [#9804](https://github.com/youzan/vant/issues/9804)
|
||||
- SubmitBar: 新增 SubmitBarTextAlign 类型 [f95567](https://github.com/commit/f95567ade758d453f4acad8a40d8ae717035476a)
|
||||
- PasswordInput: 新增 PasswordInputProps 类型 [#9820](https://github.com/issues/9820)
|
||||
- PasswordInput: 新增 PasswordInputProps 类型 [#9820](https://github.com/youzan/vant/issues/9820)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- NavBar: 修复 NavBarProps 拼写错误的问题 [#9818](https://github.com/issues/9818)
|
||||
- Progress: 修复圆角大小错误的问题 [#9826](https://github.com/issues/9826)
|
||||
- SubmitBar: 修复未导出 SubmitBarProps 的问题 [#9819](https://github.com/issues/9819)
|
||||
- Tabs: 修复 click-tab 触发顺序早于 before-change 的问题 [#9805](https://github.com/issues/9805)
|
||||
- NavBar: 修复 NavBarProps 拼写错误的问题 [#9818](https://github.com/youzan/vant/issues/9818)
|
||||
- Progress: 修复圆角大小错误的问题 [#9826](https://github.com/youzan/vant/issues/9826)
|
||||
- SubmitBar: 修复未导出 SubmitBarProps 的问题 [#9819](https://github.com/youzan/vant/issues/9819)
|
||||
- Tabs: 修复 click-tab 触发顺序早于 before-change 的问题 [#9805](https://github.com/youzan/vant/issues/9805)
|
||||
|
||||
### [v3.2.7](https://github.com/youzan/vant/compare/v3.2.6...v3.2.7)
|
||||
|
||||
|
@ -34,29 +34,36 @@ pnpm dev
|
||||
|
||||
### 目录结构
|
||||
|
||||
项目的主要目录结构如下所示:
|
||||
Vant 采用 monorepo 进行代码管理,所有子包在 `packages` 目录下:
|
||||
|
||||
```
|
||||
root
|
||||
└─ packages
|
||||
├─ vant # 组件库
|
||||
├─ vant-cli # 脚手架
|
||||
├─ vant-icons # 图标库
|
||||
├─ vant-use # Composition API
|
||||
└─ .... # 其他周边 npm 包
|
||||
```
|
||||
|
||||
其中,`vant` 目录为组件库的核心代码:
|
||||
|
||||
```
|
||||
vant
|
||||
├─ docs # 文档
|
||||
├─ packages # 基础包
|
||||
├─ src # 组件源代码
|
||||
├─ test # 单测工具类
|
||||
└─ vant.config.mjs # 文档网站配置
|
||||
├─ docs # 文档
|
||||
├─ src # 组件源代码
|
||||
├─ test # 单测工具类
|
||||
└─ vant.config.mjs # 文档网站配置
|
||||
```
|
||||
|
||||
组件代码位于 src 目录下,每个组件一个独立的文件夹。
|
||||
|
||||
### 组件目录结构
|
||||
|
||||
添加新组件时,请按照下面的目录结构组织文件,并在 `vant.config.mjs` 中配置组件名称。
|
||||
`src` 目录包含各个组件的源码,每个文件夹对应一个组件:
|
||||
|
||||
```
|
||||
src
|
||||
└─ button
|
||||
├─ demo # 示例代码
|
||||
├─ test # 单元测试
|
||||
├─ Component.ts # 组件
|
||||
├─ Component.tsx # 组件
|
||||
├─ index.ts # 组件入口
|
||||
├─ index.less # 样式
|
||||
├─ var.less # 样式变量
|
||||
@ -93,7 +100,7 @@ src
|
||||
|
||||
```bash
|
||||
# 添加主仓库到 remote,作为 fork 后仓库的上游仓库
|
||||
git remote add upstream https://github.com/youzan/vant.git
|
||||
git remote add upstream git@github.com:youzan/vant.git
|
||||
|
||||
# 拉取主仓库最新代码
|
||||
git fetch upstream
|
||||
|
@ -17,6 +17,7 @@
|
||||
- 🍭 Support Vue 2 & Vue 3
|
||||
- 🍭 Support Tree Shaking
|
||||
- 🍭 Support Custom Theme
|
||||
- 🍭 Support Accessibility (still improving)
|
||||
- 🍭 Support i18n
|
||||
- 🌍 Support SSR
|
||||
|
||||
@ -24,16 +25,14 @@
|
||||
|
||||
See in [Quickstart](#/en-US/quickstart).
|
||||
|
||||
### Contribution
|
||||
|
||||
Please make sure to read the [Contributing Guide](https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.md) before making a pull request.
|
||||
|
||||
### Browser Support
|
||||
|
||||
Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
|
||||
|
||||
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||
|
||||
## Links
|
||||
|
||||
### Official Ecosystem
|
||||
|
||||
| Project | Description |
|
||||
@ -55,12 +54,34 @@ Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||
| [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
|
||||
| [@antmjs/vantui](https://github.com/antmjs/vantui) | Mobile UI Components based on Vant, supporting Taro and React |
|
||||
|
||||
### Links
|
||||
### Other Links
|
||||
|
||||
- [Feedback](https://github.com/youzan/vant/issues)
|
||||
- [Changelog](#/en-US/changelog)
|
||||
- [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
|
||||
|
||||
## Contribution
|
||||
|
||||
### Core Team
|
||||
|
||||
Core contributors of Vant and Vant Weapp:
|
||||
|
||||
| [](https://github.com/chenjiahan/) | [](https://github.com/cookfront/) | [](https://github.com/w91/) | [](https://github.com/pangxie1991/) | [](https://github.com/rex-zsd/) | [](https://github.com/nemo-shen/) | [](https://github.com/Lindysen/) | [](https://github.com/JakeLaoyu/) |
|
||||
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
|
||||
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
|
||||
|
||||
### All Contributors
|
||||
|
||||
Thanks to the following friends for their contributions to Vant:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors" target="_black">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors" style="width: 100%; margin: 16px 0">
|
||||
</a>
|
||||
|
||||
### Contribution Guide
|
||||
|
||||
Please make sure to read the [Contributing Guide](https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.md) before making a pull request.
|
||||
|
||||
### LICENSE
|
||||
|
||||
[MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89)
|
||||
|
@ -27,6 +27,7 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源
|
||||
- 🍭 支持 Vue 2、Vue 3 和微信小程序
|
||||
- 🍭 支持主题定制,内置 700+ 个主题变量
|
||||
- 🍭 支持按需引入和 Tree Shaking
|
||||
- 🍭 支持无障碍访问(持续改进中)
|
||||
- 🍭 支持服务器端渲染
|
||||
- 🌍 支持国际化和语言包定制
|
||||
|
||||
@ -34,18 +35,14 @@ Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源
|
||||
|
||||
请阅读[快速上手](#/zh-CN/quickstart)章节,通过该章节你可以了解到 Vant 的安装方法和基本使用姿势。
|
||||
|
||||
### 贡献代码
|
||||
|
||||
贡献代码请阅读我们的[贡献指南](#/zh-CN/contribution)。
|
||||
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。
|
||||
|
||||
### 浏览器支持
|
||||
|
||||
Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。
|
||||
|
||||
Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。
|
||||
|
||||
## 链接
|
||||
|
||||
### 官方生态
|
||||
|
||||
由 Vant 官方团队维护的项目如下:
|
||||
@ -71,13 +68,37 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
| [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
|
||||
| [@antmjs/vantui](https://github.com/antmjs/vantui) | 基于 Vant Weapp 开发的多端组件库,同时支持 Taro 和 React |
|
||||
|
||||
### 链接
|
||||
### 其他链接
|
||||
|
||||
- [意见反馈](https://github.com/youzan/vant/issues)
|
||||
- [更新日志](#/zh-CN/changelog)
|
||||
- [码云镜像](https://gitee.com/vant-contrib/vant)
|
||||
- [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
|
||||
|
||||
## 贡献
|
||||
|
||||
### 核心团队
|
||||
|
||||
以下是 Vant 和 Vant Weapp 的核心贡献者们:
|
||||
|
||||
| [](https://github.com/chenjiahan/) | [](https://github.com/cookfront/) | [](https://github.com/w91/) | [](https://github.com/pangxie1991/) | [](https://github.com/rex-zsd/) | [](https://github.com/nemo-shen/) | [](https://github.com/Lindysen/) | [](https://github.com/JakeLaoyu/) |
|
||||
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
|
||||
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
|
||||
|
||||
### 贡献者们
|
||||
|
||||
感谢以下小伙伴们为 Vant 发展做出的贡献:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors" target="_black">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors" style="width: 100%; margin: 16px 0">
|
||||
</a>
|
||||
|
||||
### 贡献指南
|
||||
|
||||
贡献代码请阅读我们的[贡献指南](#/zh-CN/contribution)。
|
||||
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。
|
||||
|
||||
### 开源协议
|
||||
|
||||
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源
|
||||
|
@ -56,12 +56,21 @@ The easiest way to use Vant is to include a CDN link in the html file, after whi
|
||||
</script>
|
||||
```
|
||||
|
||||
#### Free CDN
|
||||
|
||||
You can use Vant through these free CDN services:
|
||||
|
||||
- [jsdelivr](https://www.jsdelivr.com/package/npm/vant)
|
||||
- [cdnjs](https://cdnjs.com/libraries/vant)
|
||||
- [unpkg](https://unpkg.com/)
|
||||
|
||||
Note: Free CDN is generally used for making prototypes or personal projects. It is not recommended to use free CDN in production environment.
|
||||
|
||||
For enterprise developers, we recommend:
|
||||
|
||||
- install with npm, use build tools to bundle it
|
||||
- download the scripts, host it on your own server
|
||||
|
||||
### CLI
|
||||
|
||||
We recommend to use [Vue Cli](https://cli.vuejs.org/) to create a new project.
|
||||
@ -83,16 +92,67 @@ In the GUI, click on 'Dependencies' -> `Install Dependencies` and add `vant` to
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Import on demand
|
||||
### Import on demand in vite projects (recommended)
|
||||
|
||||
Use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) to import components on demand.
|
||||
If you are using vite, please use [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import).
|
||||
|
||||
#### 1. Install Plugin
|
||||
|
||||
```bash
|
||||
npm i vite-plugin-style-import@1.2.0 -D
|
||||
```
|
||||
|
||||
#### 2. Configure Plugin
|
||||
|
||||
Configure the plugin in the `vite.config.js` file:
|
||||
|
||||
```js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style/index`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
#### 3. Import Components
|
||||
|
||||
Then you can import components from Vant:
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
import { Button } from 'vant';
|
||||
|
||||
const app = createApp();
|
||||
app.use(Button);
|
||||
```
|
||||
|
||||
> Vant supports Tree Shaking by default.
|
||||
|
||||
### Import on demand in non-vite projects (recommended)
|
||||
|
||||
In non-vite projects, use [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) to import components on demand.
|
||||
|
||||
#### 1. Install Plugin
|
||||
|
||||
```bash
|
||||
# Install plugin
|
||||
npm i babel-plugin-import -D
|
||||
```
|
||||
|
||||
Set babel config in .babelrc or babel.config.js:
|
||||
#### 2. Configure Plugin
|
||||
|
||||
Set babel config in `.babelrc` or `babel.config.js`:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -109,7 +169,9 @@ Set babel config in .babelrc or babel.config.js:
|
||||
}
|
||||
```
|
||||
|
||||
Then you can import components from vant:
|
||||
#### 3. Import Components
|
||||
|
||||
Then you can import components from Vant:
|
||||
|
||||
```js
|
||||
// Input
|
||||
@ -122,43 +184,9 @@ import 'vant/es/button/style';
|
||||
|
||||
> If you are using TypeScript,please use [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin) instead.
|
||||
|
||||
### 2. Vite Plugin
|
||||
### Import all components (not recommended)
|
||||
|
||||
If you are using Vite, please use [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import).
|
||||
|
||||
```bash
|
||||
npm i vite-plugin-style-import -D
|
||||
```
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### 3. Manually import
|
||||
|
||||
```js
|
||||
import Button from 'vant/es/button';
|
||||
import 'vant/es/button/style';
|
||||
```
|
||||
|
||||
### 4. Import all components
|
||||
Import all components will **increase the bundle size**, so this is not recommended.
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
@ -170,3 +198,13 @@ app.use(Vant);
|
||||
```
|
||||
|
||||
> If you configured babel-plugin-import, you won't be allowed to import all components.
|
||||
|
||||
### Manually import (not recommended)
|
||||
|
||||
```js
|
||||
// import script
|
||||
import Button from 'vant/es/button/index';
|
||||
// import style
|
||||
// if the component does not have a style file, there is no need to import
|
||||
import 'vant/es/button/style/index';
|
||||
```
|
||||
|
@ -61,30 +61,20 @@ pnpm add vant@3
|
||||
</script>
|
||||
```
|
||||
|
||||
#### 免费 CDN
|
||||
|
||||
你可以通过以下免费 CDN 服务来使用 Vant:
|
||||
|
||||
- [jsdelivr](https://www.jsdelivr.com/package/npm/vant)
|
||||
- [cdnjs](https://cdnjs.com/libraries/vant)
|
||||
- [unpkg](https://unpkg.com/)
|
||||
|
||||
### 通过脚手架安装
|
||||
注意:免费 CDN 一般用于制作原型或个人小型项目,不推荐在企业生产环境中使用免费 CDN。
|
||||
|
||||
在新项目中使用 Vant 时,推荐使用 Vue 官方提供的脚手架 [Vue Cli](https://cli.vuejs.org/zh/) 创建项目并安装 Vant。
|
||||
对于企业开发者,建议使用以下方式:
|
||||
|
||||
```bash
|
||||
# 安装 Vue Cli
|
||||
npm install -g @vue/cli
|
||||
|
||||
# 创建一个项目
|
||||
vue create hello-world
|
||||
|
||||
# 创建完成后,可以通过命令打开图形化界面,如下图所示
|
||||
vue ui
|
||||
```
|
||||
|
||||

|
||||
|
||||
在图形化界面中,点击 `依赖` -> `安装依赖`,然后将 `vant` 添加到依赖中即可。
|
||||
- 通过 npm 引入,并通过构建工具进行打包
|
||||
- 下载对应文件,并托管在你自己的服务器或 CDN 上
|
||||
|
||||
## 示例
|
||||
|
||||
@ -92,8 +82,9 @@ vue ui
|
||||
|
||||
我们提供了丰富的[示例工程](https://github.com/youzan/vant-demo),通过示例工程你可以了解如下内容:
|
||||
|
||||
- 基于 Vue Cli 和 Vant 搭建应用
|
||||
- 基于 Vite 和 Vant 搭建应用
|
||||
- 基于 Nuxt 和 Vant 搭建应用
|
||||
- 基于 Vue Cli 和 Vant 搭建应用
|
||||
- 配置按需引入组件
|
||||
- 配置基于 Rem 的适配方案
|
||||
- 配置基于 Viewport 的适配方案
|
||||
@ -102,15 +93,66 @@ vue ui
|
||||
|
||||
## 引入组件
|
||||
|
||||
### 方式一. 通过 babel 插件按需引入组件
|
||||
### 在 vite 项目中按需引入组件(推荐)
|
||||
|
||||
[babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 是一款 babel 插件,它会在编译过程中将 import 语句自动转换为按需引入的方式。
|
||||
在 vite 项目中使用 Vant 时,推荐安装 [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import) 插件,它可以自动按需引入组件的样式。
|
||||
|
||||
#### 1. 安装插件
|
||||
|
||||
```bash
|
||||
npm i vite-plugin-style-import@1.2.0 -D
|
||||
```
|
||||
|
||||
#### 2. 配置插件
|
||||
|
||||
安装完成后,在 `vite.config.js` 文件中配置插件:
|
||||
|
||||
```js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style/index`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
#### 3. 引入组件
|
||||
|
||||
完成以上两步,就可以直接使用 Vant 组件了:
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
import { Button } from 'vant';
|
||||
|
||||
const app = createApp();
|
||||
app.use(Button);
|
||||
```
|
||||
|
||||
> Vant 默认支持通过 Tree Shaking 实现 script 的按需引入。
|
||||
|
||||
### 在非 vite 项目中按需引入组件(推荐)
|
||||
|
||||
在非 vite 的项目中,可以通过 babel 插件来实现按需引入组件。我们需要安装 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 插件,它会在编译过程中将 import 语句自动转换为按需引入的方式。
|
||||
|
||||
#### 1. 安装插件
|
||||
|
||||
```bash
|
||||
# 安装插件
|
||||
npm i babel-plugin-import -D
|
||||
```
|
||||
|
||||
#### 2. 配置插件
|
||||
|
||||
在.babelrc 或 babel.config.js 中添加配置:
|
||||
|
||||
```json
|
||||
@ -128,6 +170,8 @@ npm i babel-plugin-import -D
|
||||
}
|
||||
```
|
||||
|
||||
#### 3. 引入组件
|
||||
|
||||
接着你可以在代码中直接引入 Vant 组件,插件会自动将代码转化为按需引入的形式。
|
||||
|
||||
```js
|
||||
@ -141,50 +185,9 @@ import 'vant/es/button/style';
|
||||
|
||||
> 如果你在使用 TypeScript,可以使用 [ts-import-plugin](https://github.com/Brooooooklyn/ts-import-plugin) 实现按需引入。
|
||||
|
||||
### 方式二. 在 Vite 项目中按需引入组件
|
||||
### 导入所有组件(不推荐)
|
||||
|
||||
对于 vite 项目,可以使用 [vite-plugin-style-import](https://github.com/anncwb/vite-plugin-style-import) 实现按需引入, 原理和 `babel-plugin-import` 类似。
|
||||
|
||||
```bash
|
||||
# 安装插件
|
||||
npm i vite-plugin-style-import -D
|
||||
```
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
styleImport({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'vant',
|
||||
esModule: true,
|
||||
resolveStyle: (name) => `vant/es/${name}/style`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### 方式三. 手动按需引入组件
|
||||
|
||||
在不使用插件的情况下,可以手动引入需要使用的组件和样式。
|
||||
|
||||
```js
|
||||
// 引入组件
|
||||
import Button from 'vant/es/button';
|
||||
// 引入组件对应的样式,若组件没有样式文件,则无须引入
|
||||
import 'vant/es/button/style';
|
||||
```
|
||||
|
||||
### 方式四. 导入所有组件
|
||||
|
||||
Vant 支持一次性导入所有组件,引入所有组件会增加代码包体积,因此不推荐这种做法。
|
||||
Vant 支持一次性导入所有组件,引入所有组件会**增加代码包体积**,因此不推荐这种做法。
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
@ -195,4 +198,16 @@ const app = createApp();
|
||||
app.use(Vant);
|
||||
```
|
||||
|
||||
> Tips: 配置按需引入后,将不允许直接导入所有组件。
|
||||
> Tips: 配置按需引入插件后,将不允许直接导入所有组件。
|
||||
|
||||
### 手动按需引入组件(不推荐)
|
||||
|
||||
在不使用任何构建插件的情况下,可以手动引入需要使用的组件和样式。
|
||||
|
||||
```js
|
||||
// 引入组件脚本
|
||||
import Button from 'vant/es/button/index';
|
||||
// 引入组件样式
|
||||
// 若组件没有样式文件,则无须引入
|
||||
import 'vant/es/button/style/index';
|
||||
```
|
||||
|
66
packages/vant/docs/markdown/use-event-listener.en-US.md
Normal file
66
packages/vant/docs/markdown/use-event-listener.en-US.md
Normal file
@ -0,0 +1,66 @@
|
||||
# useEventListener
|
||||
|
||||
### Intro
|
||||
|
||||
Attaching an event when the component is `mounted` and `activated`, then removing the event when the component is `unmounted` and `deactivated`.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```js
|
||||
import { ref } from 'vue';
|
||||
import { useEventListener } from '@vant/use';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
// attach the resize event to window
|
||||
useEventListener('resize', () => {
|
||||
console.log('window resize');
|
||||
});
|
||||
|
||||
// attach the click event to the body element
|
||||
useEventListener(
|
||||
'click',
|
||||
() => {
|
||||
console.log('click body');
|
||||
},
|
||||
{ target: document.body }
|
||||
);
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Type Declarations
|
||||
|
||||
```ts
|
||||
type Options = {
|
||||
target?: EventTarget | Ref<EventTarget>;
|
||||
capture?: boolean;
|
||||
passive?: boolean;
|
||||
};
|
||||
|
||||
function useEventListener(
|
||||
type: string,
|
||||
listener: EventListener,
|
||||
options?: Options
|
||||
): void;
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
| Name | Description | Type | Default Value |
|
||||
| -------- | ----------------- | --------------- | ------------- |
|
||||
| type | Event type | _string_ | - |
|
||||
| listener | Callback function | _EventListener_ | - |
|
||||
| options | Options | _Options_ | - |
|
||||
|
||||
### Options
|
||||
|
||||
| Name | Description | Type | Default Value |
|
||||
| --- | --- | --- | --- |
|
||||
| target | Target element | _EventTarget \| Ref\<EventTarget>_ | `window` |
|
||||
| capture | Whether to enable capture | _boolean_ | `false` |
|
||||
| passive | if true, indicates that the listener will never call `preventDefault()` | _boolean_ | `false` |
|
@ -32,6 +32,8 @@ export default {
|
||||
};
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### 类型定义
|
||||
|
||||
```ts
|
||||
@ -48,15 +50,13 @@ function useEventListener(
|
||||
): void;
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### 参数
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| -------- | ------------------------ | --------------- | ------ |
|
||||
| type | 监听的事件类型 | _string_ | - |
|
||||
| listener | 点击外部时触发的回调函数 | _EventListener_ | - |
|
||||
| options | 可选的配置项 | _Options_ | - |
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| -------- | -------------- | --------------- | ------ |
|
||||
| type | 监听的事件类型 | _string_ | - |
|
||||
| listener | 事件回调函数 | _EventListener_ | - |
|
||||
| options | 可选的配置项 | _Options_ | - |
|
||||
|
||||
### Options
|
||||
|
||||
|
@ -13,16 +13,18 @@
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { useRect } from '@vant/use';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const root = ref();
|
||||
const rect = useRect(root);
|
||||
|
||||
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
||||
|
||||
onMounted(()=>{
|
||||
const rect = useRect(root);
|
||||
console.log(rect); // -> 元素的大小及其相对于视口的位置
|
||||
})
|
||||
|
||||
return { root };
|
||||
},
|
||||
};
|
||||
|
@ -1,19 +1,34 @@
|
||||
{
|
||||
"name": "vant",
|
||||
"version": "3.2.8",
|
||||
"version": "3.3.6",
|
||||
"description": "Mobile UI Components built on Vue",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
"main": "lib/vant.cjs.js",
|
||||
"module": "lib/vant.es.js",
|
||||
"style": "lib/index.css",
|
||||
"typings": "lib/index.d.ts",
|
||||
"unpkg": "lib/vant.min.js",
|
||||
"jsdelivr": "lib/vant.min.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"import": "./lib/ssr.mjs",
|
||||
"require": "./lib/ssr.js"
|
||||
},
|
||||
"import": "./lib/vant.es.js",
|
||||
"require": "./lib/vant.cjs.js",
|
||||
"types": "./lib/index.d.ts"
|
||||
},
|
||||
"./es": "./lib/vant.es.js",
|
||||
"./lib": "./lib/vant.cjs.js",
|
||||
"./es/": "./es/",
|
||||
"./lib/": "./lib/",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"es",
|
||||
"lib",
|
||||
"vetur"
|
||||
],
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vant-cli dev",
|
||||
"lint": "vant-cli lint",
|
||||
@ -25,12 +40,19 @@
|
||||
"test:watch": "vant-cli test --watch",
|
||||
"test:coverage": "open test/coverage/index.html"
|
||||
},
|
||||
"npm": {
|
||||
"tag": "next"
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:youzan/vant.git"
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"directory": "packages/vant"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"npm": {
|
||||
"tag": "next"
|
||||
},
|
||||
"keywords": [
|
||||
"ui",
|
||||
@ -41,8 +63,6 @@
|
||||
"component",
|
||||
"components"
|
||||
],
|
||||
"author": "youzanfe",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vant/icons": "^1.7.1",
|
||||
"@vant/popperjs": "^1.1.0",
|
||||
@ -54,10 +74,11 @@
|
||||
"devDependencies": {
|
||||
"@vant/area-data": "^1.1.3",
|
||||
"@vant/cli": "workspace:*",
|
||||
"@vant/eslint-config": "workspace:*",
|
||||
"@vue/compiler-sfc": "^3.2.20",
|
||||
"@vue/runtime-core": "^3.2.20",
|
||||
"@vue/test-utils": "^2.0.0-rc.16",
|
||||
"typescript": "4.x",
|
||||
"typescript": "~4.5.2",
|
||||
"vue": "^3.2.20",
|
||||
"vue-router": "^4.0.12"
|
||||
},
|
||||
@ -67,11 +88,9 @@
|
||||
"*.css",
|
||||
"*.less"
|
||||
],
|
||||
"web-types": "vetur/web-types.json",
|
||||
"vetur": {
|
||||
"tags": "vetur/tags.json",
|
||||
"attributes": "vetur/attributes.json"
|
||||
},
|
||||
"web-types": "vetur/web-types.json",
|
||||
"unpkg": "lib/vant.min.js",
|
||||
"jsdelivr": "lib/vant.min.js"
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ exports[`should render icon slot with badge correctly 1`] = `
|
||||
>
|
||||
<div class="van-badge__wrapper van-action-bar-icon__icon">
|
||||
Custom Icon
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
1
|
||||
</div>
|
||||
</div>
|
||||
@ -45,7 +45,7 @@ exports[`should render icon slot with dot correctly 1`] = `
|
||||
>
|
||||
<div class="van-badge__wrapper van-action-bar-icon__icon">
|
||||
Custom Icon
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
</div>
|
||||
Content
|
||||
|
@ -45,7 +45,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="van-badge__wrapper van-icon van-icon-chat-o van-action-bar-icon__icon">
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
</div>
|
||||
Icon1
|
||||
@ -55,7 +55,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="van-badge__wrapper van-icon van-icon-cart-o van-action-bar-icon__icon">
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
5
|
||||
</div>
|
||||
</div>
|
||||
@ -66,7 +66,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="van-badge__wrapper van-icon van-icon-shop-o van-action-bar-icon__icon">
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
12
|
||||
</div>
|
||||
</div>
|
||||
|
@ -351,7 +351,6 @@ export default defineComponent({
|
||||
class={bem('button')}
|
||||
loading={props.isSaving}
|
||||
nativeType="submit"
|
||||
onClick={onSave}
|
||||
/>
|
||||
{props.showDelete && (
|
||||
<Button
|
||||
|
@ -17,6 +17,12 @@ import {
|
||||
|
||||
const [name, bem] = createNamespace('badge');
|
||||
|
||||
export type BadgePosition =
|
||||
| 'top-left'
|
||||
| 'top-right'
|
||||
| 'bottom-left'
|
||||
| 'bottom-right';
|
||||
|
||||
const badgeProps = {
|
||||
dot: Boolean,
|
||||
max: numericProp,
|
||||
@ -25,6 +31,7 @@ const badgeProps = {
|
||||
offset: Array as unknown as PropType<[string | number, string | number]>,
|
||||
content: numericProp,
|
||||
showZero: truthProp,
|
||||
position: makeStringProp<BadgePosition>('top-right'),
|
||||
};
|
||||
|
||||
export type BadgeProps = ExtractPropTypes<typeof badgeProps>;
|
||||
@ -87,7 +94,10 @@ export default defineComponent({
|
||||
if (hasContent() || props.dot) {
|
||||
return (
|
||||
<div
|
||||
class={bem({ dot: props.dot, fixed: !!slots.default })}
|
||||
class={bem([
|
||||
props.position,
|
||||
{ dot: props.dot, fixed: !!slots.default },
|
||||
])}
|
||||
style={style.value}
|
||||
>
|
||||
{renderContent()}
|
||||
|
@ -74,7 +74,7 @@ app.use(Badge);
|
||||
|
||||
### Custom Content
|
||||
|
||||
Use `content` slot to custom :content of badge.
|
||||
Use `content` slot to custom the content of badge.
|
||||
|
||||
```html
|
||||
<van-badge>
|
||||
@ -105,6 +105,22 @@ Use `content` slot to custom :content of badge.
|
||||
}
|
||||
```
|
||||
|
||||
### Custom Position
|
||||
|
||||
Use `position` prop to set the position of badge.
|
||||
|
||||
```html
|
||||
<van-badge :content="10" position="top-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge :content="10" position="bottom-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge :content="10" position="bottom-right">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
```
|
||||
|
||||
### Standalone
|
||||
|
||||
```html
|
||||
@ -125,6 +141,7 @@ Use `content` slot to custom :content of badge.
|
||||
| max | Max value,show `{max}+` when exceed,only works when content is number | _number \| string_ | - |
|
||||
| offset `v3.0.5` | Offset of badge dot | _[number \| string, number \| string]_ | - |
|
||||
| show-zero `v3.0.10` | Whether to show badge when content is zero | _boolean_ | `true` |
|
||||
| position `v3.2.7` | Badge position, can be set to `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
|
||||
|
||||
### Slots
|
||||
|
||||
@ -138,7 +155,7 @@ Use `content` slot to custom :content of badge.
|
||||
The component exports the following type definitions:
|
||||
|
||||
```ts
|
||||
import type { BadgeProps } from 'vant';
|
||||
import type { BadgeProps, BadgePosition } from 'vant';
|
||||
```
|
||||
|
||||
## Theming
|
||||
|
@ -111,6 +111,22 @@ app.use(Badge);
|
||||
}
|
||||
```
|
||||
|
||||
### 自定义徽标位置
|
||||
|
||||
通过 `position` 属性来设置徽标的位置。
|
||||
|
||||
```html
|
||||
<van-badge :content="10" position="top-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge :content="10" position="bottom-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge :content="10" position="bottom-right">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
```
|
||||
|
||||
### 独立展示
|
||||
|
||||
当 Badge 没有子元素时,会作为一个独立的元素进行展示。
|
||||
@ -133,6 +149,7 @@ app.use(Badge);
|
||||
| max | 最大值,超过最大值会显示 `{max}+`,仅当 content 为数字时有效 | _number \| string_ | - |
|
||||
| offset `v3.0.5` | 设置徽标的偏移量,数组的两项分别对应水平和垂直方向的偏移量,默认单位为 `px` | _[number \| string, number \| string]_ | - |
|
||||
| show-zero `v3.0.10` | 当 content 为数字 0 时,是否展示徽标 | _boolean_ | `true` |
|
||||
| position `v3.2.7` | 徽标位置,可选值为 `top-left` `bottom-left` `bottom-right` | _string_ | `top-right` |
|
||||
|
||||
### Slots
|
||||
|
||||
@ -146,7 +163,7 @@ app.use(Badge);
|
||||
组件导出以下类型定义:
|
||||
|
||||
```ts
|
||||
import type { BadgeProps } from 'vant';
|
||||
import type { BadgeProps, BadgePosition } from 'vant';
|
||||
```
|
||||
|
||||
## 主题定制
|
||||
|
@ -9,12 +9,14 @@ const t = useTranslate({
|
||||
standalone: '独立展示',
|
||||
customColor: '自定义颜色',
|
||||
customContent: '自定义徽标内容',
|
||||
customPosition: '自定义徽标位置',
|
||||
},
|
||||
'en-US': {
|
||||
max: 'Max',
|
||||
standalone: 'Standalone',
|
||||
customColor: 'Custom Color',
|
||||
customContent: 'Custom Content',
|
||||
customPosition: 'Custom Position',
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@ -80,6 +82,18 @@ const t = useTranslate({
|
||||
</van-badge>
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('customPosition')">
|
||||
<van-badge content="10" position="top-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge content="10" position="bottom-left">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
<van-badge content="10" position="bottom-right">
|
||||
<div class="child" />
|
||||
</van-badge>
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('standalone')">
|
||||
<van-badge content="20" style="margin-left: 16px" />
|
||||
<van-badge content="200" max="99" style="margin-left: 16px" />
|
||||
|
@ -28,10 +28,31 @@
|
||||
|
||||
&--fixed {
|
||||
position: absolute;
|
||||
transform-origin: 100%;
|
||||
}
|
||||
|
||||
&--top-left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
&--top-right {
|
||||
top: 0;
|
||||
right: 0;
|
||||
transform: translate(50%, -50%);
|
||||
transform-origin: 100%;
|
||||
}
|
||||
|
||||
&--bottom-left {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
transform: translate(-50%, 50%);
|
||||
}
|
||||
|
||||
&--bottom-right {
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
transform: translate(50%, 50%);
|
||||
}
|
||||
|
||||
&--dot {
|
||||
|
@ -3,4 +3,4 @@ import _Badge from './Badge';
|
||||
|
||||
export const Badge = withInstall(_Badge);
|
||||
export default Badge;
|
||||
export type { BadgeProps } from './Badge';
|
||||
export type { BadgeProps, BadgePosition } from './Badge';
|
||||
|
@ -5,28 +5,28 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
5
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
10
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
Hot
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,21 +34,21 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
9+
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
20+
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
99+
|
||||
</div>
|
||||
</div>
|
||||
@ -57,7 +57,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed"
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed"
|
||||
style="background: rgb(25, 137, 250);"
|
||||
>
|
||||
5
|
||||
@ -66,7 +66,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed"
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed"
|
||||
style="background: rgb(25, 137, 250);"
|
||||
>
|
||||
10
|
||||
@ -75,7 +75,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--dot van-badge--fixed"
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed"
|
||||
style="background: rgb(25, 137, 250);"
|
||||
>
|
||||
</div>
|
||||
@ -85,7 +85,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
<i class="van-badge__wrapper van-icon van-icon-success badge-icon">
|
||||
</i>
|
||||
</div>
|
||||
@ -93,7 +93,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
<i class="van-badge__wrapper van-icon van-icon-cross badge-icon">
|
||||
</i>
|
||||
</div>
|
||||
@ -101,19 +101,42 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
<i class="van-badge__wrapper van-icon van-icon-down badge-icon">
|
||||
</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="van-badge"
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--top-left van-badge--fixed">
|
||||
10
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--bottom-left van-badge--fixed">
|
||||
10
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-badge__wrapper">
|
||||
<div class="child">
|
||||
</div>
|
||||
<div class="van-badge van-badge--bottom-right van-badge--fixed">
|
||||
10
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="van-badge van-badge--top-right"
|
||||
style="margin-left: 16px;"
|
||||
>
|
||||
20
|
||||
</div>
|
||||
<div class="van-badge"
|
||||
<div class="van-badge van-badge--top-right"
|
||||
style="margin-left: 16px;"
|
||||
>
|
||||
99+
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should render content slot correctly 1`] = `
|
||||
<div class="van-badge">
|
||||
<div class="van-badge van-badge--top-right">
|
||||
Custom Content
|
||||
</div>
|
||||
`;
|
||||
@ -11,7 +11,7 @@ exports[`should render nothing when content is empty string 1`] = ``;
|
||||
exports[`should render nothing when content is undefined 1`] = ``;
|
||||
|
||||
exports[`should render nothing when content is zero 1`] = `
|
||||
<div class="van-badge">
|
||||
<div class="van-badge van-badge--top-right">
|
||||
0
|
||||
</div>
|
||||
`;
|
||||
|
@ -270,7 +270,7 @@ export default defineComponent({
|
||||
months.value.some((month, index) => {
|
||||
if (compareMonth(month, targetDate) === 0) {
|
||||
if (bodyRef.value) {
|
||||
monthRefs.value[index].scrollIntoView(bodyRef.value);
|
||||
monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -282,8 +282,7 @@ export default defineComponent({
|
||||
});
|
||||
};
|
||||
|
||||
// scroll to current month
|
||||
const scrollIntoView = () => {
|
||||
const scrollToCurrentDate = () => {
|
||||
if (props.poppable && !props.show) {
|
||||
return;
|
||||
}
|
||||
@ -308,13 +307,13 @@ export default defineComponent({
|
||||
// add Math.floor to avoid decimal height issues
|
||||
// https://github.com/youzan/vant/issues/5640
|
||||
bodyHeight = Math.floor(useRect(bodyRef).height);
|
||||
scrollIntoView();
|
||||
scrollToCurrentDate();
|
||||
});
|
||||
};
|
||||
|
||||
const reset = (date = getInitialDate()) => {
|
||||
currentDate.value = date;
|
||||
scrollIntoView();
|
||||
scrollToCurrentDate();
|
||||
};
|
||||
|
||||
const checkRange = (date: [Date, Date]) => {
|
||||
@ -344,15 +343,11 @@ export default defineComponent({
|
||||
const valid = checkRange(date as [Date, Date]);
|
||||
|
||||
if (!valid) {
|
||||
// auto selected to max range if showConfirm
|
||||
if (props.showConfirm) {
|
||||
setCurrentDate([
|
||||
(date as Date[])[0],
|
||||
getDayByOffset((date as Date[])[0], +props.maxRange - 1),
|
||||
]);
|
||||
} else {
|
||||
setCurrentDate(date);
|
||||
}
|
||||
// auto selected to max range
|
||||
setCurrentDate([
|
||||
(date as Date[])[0],
|
||||
getDayByOffset((date as Date[])[0], +props.maxRange - 1),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -542,7 +537,7 @@ export default defineComponent({
|
||||
() => props.defaultDate,
|
||||
(value = null) => {
|
||||
currentDate.value = value;
|
||||
scrollIntoView();
|
||||
scrollToCurrentDate();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -89,15 +89,6 @@ export default defineComponent({
|
||||
|
||||
const getTitle = () => title.value;
|
||||
|
||||
const scrollIntoView = (body: Element) => {
|
||||
const el = props.showSubtitle ? daysRef.value : monthRef.value;
|
||||
|
||||
if (el) {
|
||||
const scrollTop = useRect(el).top - useRect(body).top + body.scrollTop;
|
||||
setScrollTop(body, scrollTop);
|
||||
}
|
||||
};
|
||||
|
||||
const getMultipleDayType = (day: Date) => {
|
||||
const isSelected = (date: Date) =>
|
||||
(props.currentDate as Date[]).some(
|
||||
@ -239,6 +230,20 @@ export default defineComponent({
|
||||
days.value.filter((day) => day.type === 'disabled')
|
||||
);
|
||||
|
||||
const scrollToDate = (body: Element, targetDate: Date) => {
|
||||
if (daysRef.value) {
|
||||
const daysRect = useRect(daysRef.value);
|
||||
const totalRows = placeholders.value.length;
|
||||
const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
|
||||
const rowOffset = ((currentRow - 1) * daysRect.height) / totalRows;
|
||||
|
||||
setScrollTop(
|
||||
body,
|
||||
daysRect.top + rowOffset + body.scrollTop - useRect(body).top
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const renderDay = (item: CalendarDayItem, index: number) => (
|
||||
<CalendarDay
|
||||
v-slots={pick(slots, ['top-info', 'bottom-info'])}
|
||||
@ -262,7 +267,7 @@ export default defineComponent({
|
||||
getTitle,
|
||||
getHeight: () => height.value,
|
||||
setVisible,
|
||||
scrollIntoView,
|
||||
scrollToDate,
|
||||
disabledDays,
|
||||
});
|
||||
|
||||
|
@ -2,36 +2,7 @@ import { Calendar } from '..';
|
||||
import { mount, later } from '../../../test';
|
||||
import { minDate, maxDate } from './utils';
|
||||
|
||||
test('max-range prop when type is range and showConfirm is false', async () => {
|
||||
const wrapper = mount(Calendar, {
|
||||
props: {
|
||||
type: 'range',
|
||||
minDate,
|
||||
maxDate,
|
||||
maxRange: 3,
|
||||
poppable: false,
|
||||
showConfirm: false,
|
||||
lazyRender: false,
|
||||
},
|
||||
});
|
||||
|
||||
await later();
|
||||
|
||||
const days = wrapper.findAll('.van-calendar__day');
|
||||
days[12].trigger('click');
|
||||
days[18].trigger('click');
|
||||
|
||||
expect(wrapper.emitted<[Date]>('select')![0][0]).toEqual([
|
||||
new Date(2010, 0, 13),
|
||||
]);
|
||||
expect(wrapper.emitted<[Date]>('select')![1][0]).toEqual([
|
||||
new Date(2010, 0, 13),
|
||||
new Date(2010, 0, 19),
|
||||
]);
|
||||
expect(wrapper.emitted('confirm')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('max-range prop when type is range and showConfirm is true', async () => {
|
||||
test('should limit max range when using max-range prop and type is range', async () => {
|
||||
const wrapper = mount(Calendar, {
|
||||
props: {
|
||||
type: 'range',
|
||||
@ -59,7 +30,7 @@ test('max-range prop when type is range and showConfirm is true', async () => {
|
||||
expect(wrapper.emitted('confirm')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('max-range prop when type is multiple', async () => {
|
||||
test('should limit max range when using max-range prop and type is multiple', async () => {
|
||||
const wrapper = mount(Calendar, {
|
||||
props: {
|
||||
type: 'multiple',
|
||||
|
@ -42,7 +42,7 @@ export type CalendarMonthInstance = ComponentPublicInstance<
|
||||
getTitle: () => string;
|
||||
getHeight: () => number;
|
||||
setVisible: (value?: boolean | undefined) => void;
|
||||
scrollIntoView: (body: Element) => void;
|
||||
scrollToDate: (body: Element, targetDate: Date) => void;
|
||||
disabledDays: Ref<ComputedRef<CalendarDayItem[]>>;
|
||||
}
|
||||
>;
|
||||
|
@ -51,23 +51,19 @@ const imageURL = 'https://img.yzcdn.cn/vant/ipad.jpeg';
|
||||
:thumb="imageURL"
|
||||
>
|
||||
<template #tags>
|
||||
<div>
|
||||
<van-tag plain type="danger" style="margin-right: 5px">
|
||||
{{ t('tag') }}
|
||||
</van-tag>
|
||||
<van-tag plain type="danger">{{ t('tag') }}</van-tag>
|
||||
</div>
|
||||
<van-tag plain type="danger" style="margin-right: 5px">
|
||||
{{ t('tag') }}
|
||||
</van-tag>
|
||||
<van-tag plain type="danger">{{ t('tag') }}</van-tag>
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
<div>
|
||||
<van-button round size="mini">
|
||||
{{ t('button') }}
|
||||
</van-button>
|
||||
<van-button round size="mini">
|
||||
{{ t('button') }}
|
||||
</van-button>
|
||||
</div>
|
||||
<van-button round size="mini">
|
||||
{{ t('button') }}
|
||||
</van-button>
|
||||
<van-button round size="mini">
|
||||
{{ t('button') }}
|
||||
</van-button>
|
||||
</template>
|
||||
</van-card>
|
||||
</demo-block>
|
||||
|
@ -134,18 +134,16 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-card__desc van-ellipsis">
|
||||
Description
|
||||
</div>
|
||||
<div>
|
||||
<transition-stub style="margin-right: 5px;">
|
||||
<span class="van-tag van-tag--plain van-tag--danger">
|
||||
Tag
|
||||
</span>
|
||||
</transition-stub>
|
||||
<transition-stub>
|
||||
<span class="van-tag van-tag--plain van-tag--danger">
|
||||
Tag
|
||||
</span>
|
||||
</transition-stub>
|
||||
</div>
|
||||
<transition-stub style="margin-right: 5px;">
|
||||
<span class="van-tag van-tag--plain van-tag--danger">
|
||||
Tag
|
||||
</span>
|
||||
</transition-stub>
|
||||
<transition-stub>
|
||||
<span class="van-tag van-tag--plain van-tag--danger">
|
||||
Tag
|
||||
</span>
|
||||
</transition-stub>
|
||||
</div>
|
||||
<div class="van-card__bottom">
|
||||
<div class="van-card__price">
|
||||
@ -169,26 +167,24 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-card__footer">
|
||||
<div>
|
||||
<button type="button"
|
||||
class="van-button van-button--default van-button--mini van-button--round"
|
||||
>
|
||||
<div class="van-button__content">
|
||||
<span class="van-button__text">
|
||||
Button
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="van-button van-button--default van-button--mini van-button--round"
|
||||
>
|
||||
<div class="van-button__content">
|
||||
<span class="van-button__text">
|
||||
Button
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<button type="button"
|
||||
class="van-button van-button--default van-button--mini van-button--round"
|
||||
>
|
||||
<div class="van-button__content">
|
||||
<span class="van-button__text">
|
||||
Button
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="van-button van-button--default van-button--mini van-button--round"
|
||||
>
|
||||
<div class="van-button__content">
|
||||
<span class="van-button__text">
|
||||
Button
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -248,7 +248,7 @@ export default {
|
||||
| --- | --- | --- | --- |
|
||||
| title | Title | _string_ | - |
|
||||
| value | Value of selected option | _string \| number_ | - |
|
||||
| options | Options | _Option[]_ | `[]` |
|
||||
| options | Options | _CascaderOption[]_ | `[]` |
|
||||
| placeholder | Placeholder of unselected tab | _string_ | `Select` |
|
||||
| active-color | Active color | _string_ | `#ee0a24` |
|
||||
| swipeable `v3.0.11` | Whether to enable gestures to slide left and right | _boolean_ | `false` |
|
||||
@ -256,14 +256,14 @@ export default {
|
||||
| close-icon `v3.0.10` | Close icon name | _string_ | `cross` |
|
||||
| field-names `v3.0.4` | Custom the fields of options | _object_ | `{ text: 'text', value: 'value', children: 'children' }` |
|
||||
|
||||
### Data Structure of Option
|
||||
### Data Structure of CascaderOption
|
||||
|
||||
| Key | Description | Type |
|
||||
| ------------------ | ------------------------- | --------------------------- |
|
||||
| text | Option text | _string_ |
|
||||
| value | Option value | _string \| number_ |
|
||||
| color `v3.1.0` | Text color | _string_ |
|
||||
| children | Cascade children | _Option[]_ |
|
||||
| children | Cascade children | _CascaderOption[]_ |
|
||||
| disabled `v3.1.2` | Whether to disable option | _boolean_ |
|
||||
| className `v3.1.0` | className for the option | _string \| Array \| object_ |
|
||||
|
||||
@ -271,8 +271,8 @@ export default {
|
||||
|
||||
| Event | Description | Arguments |
|
||||
| --- | --- | --- |
|
||||
| change | Emitted when active option changed | `{ value, selectedOptions, tabIndex }` |
|
||||
| finish | Emitted when all options is selected | `{ value, selectedOptions, tabIndex }` |
|
||||
| change | Emitted when active option changed | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ |
|
||||
| finish | Emitted when all options is selected | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ |
|
||||
| close | Emitted when the close icon is clicked | - |
|
||||
| click-tab | Emitted when a tab is clicked | _activeTab: number, title: string_ |
|
||||
|
||||
@ -281,7 +281,7 @@ export default {
|
||||
| Name | Description | SlotProps |
|
||||
| --- | --- | --- |
|
||||
| title | Custom title | - |
|
||||
| option `v3.1.4` | Custom option text | _{ option: Option, selected: boolean }_ |
|
||||
| option `v3.1.4` | Custom option text | _{ option: CascaderOption, selected: boolean }_ |
|
||||
| options-top `v3.2.7` | Custom the content above the options | _{ tabIndex: number }_ |
|
||||
| options-bottom `v3.2.8` | Custom the content below the options | _{ tabIndex: number }_ |
|
||||
|
||||
|
@ -258,7 +258,7 @@ export default {
|
||||
| --- | --- | --- | --- |
|
||||
| title | 顶部标题 | _string_ | - |
|
||||
| value | 选中项的值 | _string \| number_ | - |
|
||||
| options | 可选项数据源 | _Option[]_ | `[]` |
|
||||
| options | 可选项数据源 | _CascaderOption[]_ | `[]` |
|
||||
| placeholder | 未选中时的提示文案 | _string_ | `请选择` |
|
||||
| active-color | 选中状态的高亮颜色 | _string_ | `#ee0a24` |
|
||||
| swipeable `v3.0.11` | 是否开启手势左右滑动切换 | _boolean_ | `false` |
|
||||
@ -266,7 +266,7 @@ export default {
|
||||
| close-icon `v3.0.10` | 关闭[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `cross` |
|
||||
| field-names `v3.0.4` | 自定义 `options` 结构中的字段 | _object_ | `{ text: 'text', value: 'value', children: 'children' }` |
|
||||
|
||||
### Option 数据结构
|
||||
### CascaderOption 数据结构
|
||||
|
||||
`options` 属性是一个由对象构成的数组,数组中的每个对象配置一个可选项,对象可以包含以下值:
|
||||
|
||||
@ -275,25 +275,25 @@ export default {
|
||||
| text | 选项文字(必填) | _string_ |
|
||||
| value | 选项对应的值(必填) | _string \| number_ |
|
||||
| color `v3.1.0` | 选项文字颜色 | _string_ |
|
||||
| children | 子选项列表 | _Option[]_ |
|
||||
| children | 子选项列表 | _CascaderOption[]_ |
|
||||
| disabled `v3.1.2` | 是否禁用选项 | _boolean_ |
|
||||
| className `v3.1.0` | 为对应列添加额外的 class | _string \| Array \| object_ |
|
||||
|
||||
### Events
|
||||
|
||||
| 事件 | 说明 | 回调参数 |
|
||||
| --------- | ---------------------- | -------------------------------------- |
|
||||
| change | 选中项变化时触发 | `{ value, selectedOptions, tabIndex }` |
|
||||
| finish | 全部选项选择完成后触发 | `{ value, selectedOptions, tabIndex }` |
|
||||
| close | 点击关闭图标时触发 | - |
|
||||
| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ |
|
||||
| 事件 | 说明 | 回调参数 |
|
||||
| --- | --- | --- |
|
||||
| change | 选中项变化时触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ |
|
||||
| finish | 全部选项选择完成后触发 | _{ value: string \| number, selectedOptions: CascaderOption[], tabIndex: number }_ |
|
||||
| close | 点击关闭图标时触发 | - |
|
||||
| click-tab | 点击标签时触发 | _tabIndex: number, title: string_ |
|
||||
|
||||
### Slots
|
||||
|
||||
| 名称 | 说明 | 参数 |
|
||||
| --- | --- | --- |
|
||||
| title | 自定义顶部标题 | - |
|
||||
| option `v3.1.4` | 自定义选项文字 | _{ option: Option, selected: boolean }_ |
|
||||
| option `v3.1.4` | 自定义选项文字 | _{ option: CascaderOption, selected: boolean }_ |
|
||||
| options-top `v3.2.7` | 自定义选项上方的内容 | _{ tabIndex: number }_ |
|
||||
| options-bottom `v3.2.8` | 自定义选项下方的内容 | _{ tabIndex: number }_ |
|
||||
|
||||
|
@ -55,7 +55,7 @@ const t = useTranslate({
|
||||
|
||||
type StateItem = {
|
||||
show: boolean;
|
||||
value: string | number | null;
|
||||
value: string | number | undefined;
|
||||
result: string;
|
||||
options?: CascaderOption[];
|
||||
tabIndex?: number;
|
||||
@ -68,18 +68,18 @@ const baseState = reactive<StateItem>({
|
||||
});
|
||||
const customColorState = reactive<StateItem>({
|
||||
show: false,
|
||||
value: null,
|
||||
value: undefined,
|
||||
result: '',
|
||||
});
|
||||
const asyncState = reactive<StateItem>({
|
||||
show: false,
|
||||
value: null,
|
||||
value: undefined,
|
||||
result: '',
|
||||
options: t('asyncOptions1'),
|
||||
});
|
||||
const customFieldState = reactive<StateItem>({
|
||||
show: false,
|
||||
value: null,
|
||||
value: undefined,
|
||||
result: '',
|
||||
});
|
||||
|
||||
@ -91,7 +91,7 @@ const fieldNames = {
|
||||
|
||||
const customContentState = reactive<StateItem>({
|
||||
show: false,
|
||||
value: null,
|
||||
value: undefined,
|
||||
result: '',
|
||||
});
|
||||
|
||||
|
@ -111,7 +111,7 @@ exports[`should update tabs when previous tab is clicked 1`] = `
|
||||
<div style="transition-duration: 0ms; transform: translateX(0px); width: 200px;"
|
||||
class="van-swipe__track"
|
||||
>
|
||||
<div class="van-swipe-item van-tab__pane-wrapper van-tab__pane-wrapper--inactive"
|
||||
<div class="van-swipe-item van-tab__panel-wrapper van-tab__panel-wrapper--inactive"
|
||||
id="van-tab"
|
||||
role="tabpanel"
|
||||
tabindex="-1"
|
||||
@ -146,7 +146,7 @@ exports[`should update tabs when previous tab is clicked 1`] = `
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-swipe-item van-tab__pane-wrapper"
|
||||
<div class="van-swipe-item van-tab__panel-wrapper"
|
||||
id="van-tab"
|
||||
role="tabpanel"
|
||||
tabindex="0"
|
||||
|
@ -25,9 +25,9 @@ Use `v-model` to control the name of active panels.
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeNames">
|
||||
<van-collapse-item title="Title1" name="1">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title3" name="3">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title1" name="1">Content 1</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2">Content 2</van-collapse-item>
|
||||
<van-collapse-item title="Title3" name="3">Content 3</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
@ -48,9 +48,9 @@ In accordion mode, only one panel can be expanded at the same time.
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeName" accordion>
|
||||
<van-collapse-item title="Title1" name="1">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title3" name="3">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title1" name="1">Content 1</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2">Content 2</van-collapse-item>
|
||||
<van-collapse-item title="Title3" name="3">Content 3</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
@ -71,12 +71,12 @@ Use the `disabled` prop to disable CollapseItem.
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeNames">
|
||||
<van-collapse-item title="Title1" name="1">Content</van-collapse-item>
|
||||
<van-collapse-item title="Title1" name="1">Content 1</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2" disabled>
|
||||
Content
|
||||
Content 2
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="Title3" name="3" disabled>
|
||||
Content
|
||||
Content 3
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
@ -89,10 +89,10 @@ Use the `disabled` prop to disable CollapseItem.
|
||||
<template #title>
|
||||
<div>Title1 <van-icon name="question-o" /></div>
|
||||
</template>
|
||||
Content
|
||||
Content 1
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="Title2" name="2" icon="shop-o">
|
||||
Content
|
||||
Content 2
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
@ -25,9 +25,15 @@ app.use(CollapseItem);
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeNames">
|
||||
<van-collapse-item title="标题1" name="1">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题1" name="1">
|
||||
代码是写出来给人看的,附带能在机器上运行。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2">
|
||||
技术无非就是那些开发它的人的共同灵魂。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3">
|
||||
在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
@ -48,9 +54,15 @@ export default {
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeName" accordion>
|
||||
<van-collapse-item title="标题1" name="1">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题1" name="1">
|
||||
代码是写出来给人看的,附带能在机器上运行。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2">
|
||||
技术无非就是那些开发它的人的共同灵魂。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3">
|
||||
在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
@ -71,9 +83,15 @@ export default {
|
||||
|
||||
```html
|
||||
<van-collapse v-model="activeNames">
|
||||
<van-collapse-item title="标题1" name="1">内容</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2" disabled>内容</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3" disabled>内容</van-collapse-item>
|
||||
<van-collapse-item title="标题1" name="1">
|
||||
代码是写出来给人看的,附带能在机器上运行。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2" disabled>
|
||||
技术无非就是那些开发它的人的共同灵魂。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题3" name="3" disabled>
|
||||
在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
||||
@ -87,10 +105,10 @@ export default {
|
||||
<template #title>
|
||||
<div>标题1 <van-icon name="question-o" /></div>
|
||||
</template>
|
||||
内容
|
||||
代码是写出来给人看的,附带能在机器上运行。
|
||||
</van-collapse-item>
|
||||
<van-collapse-item title="标题2" name="2" icon="shop-o">
|
||||
内容
|
||||
技术无非就是那些开发它的人的共同灵魂。
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
```
|
||||
|
@ -7,14 +7,18 @@ import { useTranslate } from '../../../docs/site/use-translate';
|
||||
|
||||
const t = useTranslate({
|
||||
'zh-CN': {
|
||||
text1: '代码是写出来给人看的,附带能在机器上运行。',
|
||||
text2: '技术无非就是那些开发它的人的共同灵魂。',
|
||||
text3: '在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。',
|
||||
accordion: '手风琴',
|
||||
titleSlot: '自定义标题内容',
|
||||
text: '代码是写出来给人看的,附带能在机器上运行',
|
||||
},
|
||||
'en-US': {
|
||||
text1: 'Content 1',
|
||||
text2: 'Content 2',
|
||||
text3: 'Content 3',
|
||||
accordion: 'Accordion',
|
||||
titleSlot: 'Custom title',
|
||||
text: 'Content',
|
||||
},
|
||||
});
|
||||
|
||||
@ -28,13 +32,13 @@ const active4 = ref([]);
|
||||
<demo-block :title="t('basicUsage')">
|
||||
<van-collapse v-model="active1">
|
||||
<van-collapse-item :title="t('title') + 1">
|
||||
{{ t('text') }}
|
||||
{{ t('text1') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 2">
|
||||
{{ t('text') }}
|
||||
{{ t('text2') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 3">
|
||||
{{ t('text') }}
|
||||
{{ t('text3') }}
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</demo-block>
|
||||
@ -42,13 +46,13 @@ const active4 = ref([]);
|
||||
<demo-block :title="t('accordion')">
|
||||
<van-collapse v-model="active2" accordion>
|
||||
<van-collapse-item :title="t('title') + 1">
|
||||
{{ t('text') }}
|
||||
{{ t('text1') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 2">
|
||||
{{ t('text') }}
|
||||
{{ t('text2') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 3">
|
||||
{{ t('text') }}
|
||||
{{ t('text3') }}
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</demo-block>
|
||||
@ -56,13 +60,13 @@ const active4 = ref([]);
|
||||
<demo-block :title="t('disabled')">
|
||||
<van-collapse v-model="active3">
|
||||
<van-collapse-item :title="t('title') + 1">
|
||||
{{ t('text') }}
|
||||
{{ t('text1') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 2" disabled>
|
||||
{{ t('text') }}
|
||||
{{ t('text2') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item :title="t('title') + 3" disabled>
|
||||
{{ t('text') }}
|
||||
{{ t('text3') }}
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</demo-block>
|
||||
@ -73,14 +77,14 @@ const active4 = ref([]);
|
||||
<template #title>
|
||||
{{ t('title') + 1 }}<van-icon name="question-o" />
|
||||
</template>
|
||||
{{ t('text') }}
|
||||
{{ t('text1') }}
|
||||
</van-collapse-item>
|
||||
<van-collapse-item
|
||||
:title="t('title') + 2"
|
||||
:value="t('content')"
|
||||
icon="shop-o"
|
||||
>
|
||||
{{ t('text') }}
|
||||
{{ t('text2') }}
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</demo-block>
|
||||
|
@ -19,7 +19,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
<div class="van-collapse-item__wrapper">
|
||||
<div class="van-collapse-item__content">
|
||||
Content
|
||||
Content 1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -73,7 +73,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
<div class="van-collapse-item__wrapper">
|
||||
<div class="van-collapse-item__content">
|
||||
Content
|
||||
Content 1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -120,7 +120,7 @@ Vant 中的 CSS 变量分为 **基础变量** 和 **组件变量**。组件变
|
||||
|
||||
#### 修改变量
|
||||
|
||||
由于 CSS 变量继承机制的原因, 两者的修改方式有一定差异:
|
||||
由于 CSS 变量继承机制的原因,两者的修改方式有一定差异:
|
||||
|
||||
- 基础变量只能通过 `root 选择器` 修改,不能通过 `ConfigProvider 组件` 修改。
|
||||
- 组件变量可以通过 `root 选择器` 和 `ConfigProvider 组件` 修改。
|
||||
|
@ -58,7 +58,7 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
return () => (
|
||||
<div class={bem()}>
|
||||
<div role="timer" class={bem()}>
|
||||
{slots.default ? slots.default(current.value) : timeText.value}
|
||||
</div>
|
||||
);
|
||||
|
@ -1,31 +1,41 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should format S milliseconds correctly 1`] = `
|
||||
<div class="van-count-down">
|
||||
<div role="timer"
|
||||
class="van-count-down"
|
||||
>
|
||||
01-5
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`should format SS milliseconds correctly 1`] = `
|
||||
<div class="van-count-down">
|
||||
<div role="timer"
|
||||
class="van-count-down"
|
||||
>
|
||||
01-50
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`should format complete time correctly 1`] = `
|
||||
<div class="van-count-down">
|
||||
<div role="timer"
|
||||
class="van-count-down"
|
||||
>
|
||||
01-05-59-59-999
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`should format incomplete time correctly 1`] = `
|
||||
<div class="van-count-down">
|
||||
<div role="timer"
|
||||
class="van-count-down"
|
||||
>
|
||||
29-59-59-999
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`should not start counting when auto-start prop is false 1`] = `
|
||||
<div class="van-count-down">
|
||||
<div role="timer"
|
||||
class="van-count-down"
|
||||
>
|
||||
100
|
||||
</div>
|
||||
`;
|
||||
|
@ -58,13 +58,13 @@ export default {
|
||||
```js
|
||||
Dialog.alert({
|
||||
title: '标题',
|
||||
message: '弹窗内容',
|
||||
message: '代码是写出来给人看的,附带能在机器上运行。',
|
||||
}).then(() => {
|
||||
// on close
|
||||
});
|
||||
|
||||
Dialog.alert({
|
||||
message: '弹窗内容',
|
||||
message: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。',
|
||||
}).then(() => {
|
||||
// on close
|
||||
});
|
||||
@ -77,7 +77,8 @@ Dialog.alert({
|
||||
```js
|
||||
Dialog.confirm({
|
||||
title: '标题',
|
||||
message: '弹窗内容',
|
||||
message:
|
||||
'如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。',
|
||||
})
|
||||
.then(() => {
|
||||
// on confirm
|
||||
@ -94,14 +95,14 @@ Dialog.confirm({
|
||||
```js
|
||||
Dialog.alert({
|
||||
title: '标题',
|
||||
message: '弹窗内容',
|
||||
message: '代码是写出来给人看的,附带能在机器上运行。',
|
||||
theme: 'round-button',
|
||||
}).then(() => {
|
||||
// on close
|
||||
});
|
||||
|
||||
Dialog.alert({
|
||||
message: '弹窗内容',
|
||||
message: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。',
|
||||
theme: 'round-button',
|
||||
}).then(() => {
|
||||
// on close
|
||||
@ -127,7 +128,8 @@ const beforeClose = (action) =>
|
||||
|
||||
Dialog.confirm({
|
||||
title: '标题',
|
||||
message: '弹窗内容',
|
||||
message:
|
||||
'如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。',
|
||||
beforeClose,
|
||||
});
|
||||
```
|
||||
|
@ -3,7 +3,7 @@ import VanCell from '../../cell';
|
||||
import { Dialog } from '..';
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '../../../docs/site/use-translate';
|
||||
import type { DialogAction } from '../Dialog';
|
||||
import type { DialogAction } from '../types';
|
||||
|
||||
const VanDialog = Dialog.Component;
|
||||
|
||||
@ -13,16 +13,22 @@ const t = useTranslate({
|
||||
alert1: '提示弹窗',
|
||||
alert2: '提示弹窗(无标题)',
|
||||
confirm: '确认弹窗',
|
||||
content1: '代码是写出来给人看的,附带能在机器上运行。',
|
||||
content2: '生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。',
|
||||
content3:
|
||||
'如果解决方法是丑陋的,那就肯定还有更好的解决方法,只是还没有发现而已。',
|
||||
beforeClose: '异步关闭',
|
||||
roundButton: '圆角按钮样式',
|
||||
componentCall: '组件调用',
|
||||
content: '代码是写出来给人看的,附带能在机器上运行',
|
||||
},
|
||||
'en-US': {
|
||||
title: 'Title',
|
||||
alert1: 'Alert',
|
||||
alert2: 'Alert without title',
|
||||
confirm: 'Confirm dialog',
|
||||
content1: 'Content',
|
||||
content2: 'Content',
|
||||
content3: 'Content',
|
||||
beforeClose: 'Before Close',
|
||||
roundButton: 'Round Button Style',
|
||||
componentCall: 'Component Call',
|
||||
@ -35,13 +41,13 @@ const image = 'https://img.yzcdn.cn/vant/apple-3.jpg';
|
||||
const onClickAlert = () => {
|
||||
Dialog.alert({
|
||||
title: t('title'),
|
||||
message: t('content'),
|
||||
message: t('content1'),
|
||||
});
|
||||
};
|
||||
|
||||
const onClickAlert2 = () => {
|
||||
Dialog.alert({
|
||||
message: t('content'),
|
||||
message: t('content2'),
|
||||
});
|
||||
};
|
||||
|
||||
@ -49,21 +55,21 @@ const onClickRound = () => {
|
||||
Dialog.alert({
|
||||
theme: 'round-button',
|
||||
title: t('title'),
|
||||
message: t('content'),
|
||||
message: t('content1'),
|
||||
});
|
||||
};
|
||||
|
||||
const onClickRound2 = () => {
|
||||
Dialog.alert({
|
||||
theme: 'round-button',
|
||||
message: t('content'),
|
||||
message: t('content2'),
|
||||
});
|
||||
};
|
||||
|
||||
const onClickConfirm = () => {
|
||||
Dialog.confirm({
|
||||
title: t('title'),
|
||||
message: t('content'),
|
||||
message: t('content3'),
|
||||
});
|
||||
};
|
||||
|
||||
@ -75,7 +81,7 @@ const onClickBeforeClose = () => {
|
||||
|
||||
Dialog.confirm({
|
||||
title: t('title'),
|
||||
message: t('content'),
|
||||
message: t('content3'),
|
||||
beforeClose,
|
||||
});
|
||||
};
|
||||
|
@ -431,9 +431,9 @@ export default {
|
||||
setup() {
|
||||
const result = ref('');
|
||||
const showArea = ref(false);
|
||||
const onConfirm = (value) => {
|
||||
const onConfirm = (areaValues) => {
|
||||
showArea.value = false;
|
||||
result.value = values
|
||||
result.value = areaValues
|
||||
.filter((item) => !!item)
|
||||
.map((item) => item.name)
|
||||
.join('/');
|
||||
@ -492,7 +492,7 @@ export default {
|
||||
| Attribute | Description | Type | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| label-width | Field label width | _number \| string_ | `6.2em` |
|
||||
| label-align | Field label align, can be set to `center` `right` | _string_ | `left` |
|
||||
| label-align | Field label align, can be set to `center` `right` | _string_ | `left` |
|
||||
| input-align | Field input align, can be set to `center` `right` | _string_ | `left` |
|
||||
| error-message-align | Error message align, can be set to `center` `right` | _string_ | `left` |
|
||||
| validate-trigger | When to validate the form,can be set to `onChange`、`onSubmit` | _string_ | `onBlur` |
|
||||
@ -509,7 +509,7 @@ export default {
|
||||
|
||||
| Key | Description | Type |
|
||||
| --- | --- | --- |
|
||||
| required | Whether to be a required field | _boolean_ |
|
||||
| required | Whether to be a required field, the value is not allowed to be empty string, empty array, `undefined`, `null` | _boolean_ |
|
||||
| message | Error message | _string \| (value, rule) => string_ |
|
||||
| validator | Custom validator | _(value, rule) => boolean \| string \| Promise_ |
|
||||
| pattern | Regex pattern | _RegExp_ |
|
||||
|
@ -461,9 +461,9 @@ export default {
|
||||
setup() {
|
||||
const result = ref('');
|
||||
const showArea = ref(false);
|
||||
const onConfirm = (value) => {
|
||||
const onConfirm = (areaValues) => {
|
||||
showArea.value = false;
|
||||
result.value = values
|
||||
result.value = areaValues
|
||||
.filter((item) => !!item)
|
||||
.map((item) => item.name)
|
||||
.join('/');
|
||||
@ -524,7 +524,7 @@ export default {
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| label-width | 表单项 label 宽度,默认单位为`px` | _number \| string_ | `6.2em` |
|
||||
| label-align | 表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` |
|
||||
| label-align | 表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` |
|
||||
| input-align | 输入框对齐方式,可选值为 `center` `right` | _string_ | `left` |
|
||||
| error-message-align | 错误提示文案对齐方式,可选值为 `center` `right` | _string_ | `left` |
|
||||
| validate-trigger | 表单校验触发时机,可选值为 `onChange`、`onSubmit`,详见下表 | _string_ | `onBlur` |
|
||||
@ -545,14 +545,14 @@ export default {
|
||||
|
||||
| 键名 | 说明 | 类型 |
|
||||
| --- | --- | --- |
|
||||
| required | 是否为必选字段 | _boolean_ |
|
||||
| required | 是否为必选字段,当值为空字符串、空数组、`undefined`、`null` 时,校验不通过 | _boolean_ |
|
||||
| message | 错误提示文案 | _string \| (value, rule) => string_ |
|
||||
| validator | 通过函数进行校验 | _(value, rule) => boolean \| string \| Promise_ |
|
||||
| pattern | 通过正则表达式进行校验 | _RegExp_ |
|
||||
| trigger | 本项规则的触发时机,可选值为 `onChange`、`onBlur` | _string_ |
|
||||
| formatter | 格式化函数,将表单项的值转换后进行校验 | _(value, rule) => any_ |
|
||||
|
||||
### validate-trigger 可选值
|
||||
### validate-trigger 可选值
|
||||
|
||||
通过 `validate-trigger` 属性可以自定义表单校验的触发时机。
|
||||
|
||||
|
@ -23,8 +23,8 @@ const t = useTranslate({
|
||||
const areaCode = ref('');
|
||||
const showArea = ref(false);
|
||||
|
||||
const onConfirm = (values: AreaColumnOption[]) => {
|
||||
areaCode.value = values
|
||||
const onConfirm = (areaValues: AreaColumnOption[]) => {
|
||||
areaCode.value = areaValues
|
||||
.filter((item) => !!item)
|
||||
.map((item) => item.name)
|
||||
.join('/');
|
||||
|
@ -459,7 +459,11 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="van-uploader__preview-delete">
|
||||
<div role="button"
|
||||
class="van-uploader__preview-delete"
|
||||
tabindex="0"
|
||||
aria-label="Delete"
|
||||
>
|
||||
<i class="van-badge__wrapper van-icon van-icon-cross van-uploader__preview-delete-icon">
|
||||
</i>
|
||||
</div>
|
||||
|
@ -433,7 +433,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<div class="van-grid-item__content van-grid-item__content--center van-hairline">
|
||||
<i class="van-badge__wrapper van-icon van-icon-home-o van-grid-item__icon">
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
</i>
|
||||
<span class="van-grid-item__text">
|
||||
@ -446,7 +446,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<div class="van-grid-item__content van-grid-item__content--center van-hairline">
|
||||
<i class="van-badge__wrapper van-icon van-icon-search van-grid-item__icon">
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
99+
|
||||
</div>
|
||||
</i>
|
||||
|
@ -8,7 +8,7 @@ exports[`should render icon-slot correctly 1`] = `
|
||||
<div class="van-grid-item__content van-grid-item__content--center van-hairline">
|
||||
<div class="van-badge__wrapper">
|
||||
Custom Icon
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
1
|
||||
</div>
|
||||
</div>
|
||||
|
@ -93,7 +93,7 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
|
||||
<template>
|
||||
<van-tabs v-model:active="tab" sticky>
|
||||
<van-tab :title="t('demo')">
|
||||
<van-tab class="demo-icon-tab-panel" :title="t('demo')">
|
||||
<demo-block :title="t('basicUsage')">
|
||||
<van-row>
|
||||
<van-col span="6" @click="copy(demoIcon)">
|
||||
@ -142,7 +142,7 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
</demo-block>
|
||||
</van-tab>
|
||||
|
||||
<van-tab :title="t('basic')">
|
||||
<van-tab class="demo-icon-tab-panel" :title="t('basic')">
|
||||
<van-row>
|
||||
<van-col
|
||||
v-for="icon in icons.basic"
|
||||
@ -156,7 +156,7 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
</van-row>
|
||||
</van-tab>
|
||||
|
||||
<van-tab :title="t('outline')">
|
||||
<van-tab class="demo-icon-tab-panel" :title="t('outline')">
|
||||
<van-row>
|
||||
<van-col
|
||||
v-for="icon in icons.outline"
|
||||
@ -170,7 +170,7 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
</van-row>
|
||||
</van-tab>
|
||||
|
||||
<van-tab :title="t('filled')">
|
||||
<van-tab class="demo-icon-tab-panel" :title="t('filled')">
|
||||
<van-row>
|
||||
<van-col
|
||||
v-for="icon in icons.filled"
|
||||
@ -190,16 +190,17 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
.demo-icon {
|
||||
font-size: 0;
|
||||
|
||||
&-list {
|
||||
box-sizing: border-box;
|
||||
min-height: calc(100vh - 65px);
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
&-notify {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&-tab-panel {
|
||||
width: auto;
|
||||
margin: 20px;
|
||||
background-color: var(--van-background-color-light);
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.van-col {
|
||||
display: inline-block;
|
||||
float: none;
|
||||
@ -227,12 +228,5 @@ const copy = (icon: string, option: Record<string, unknown> = {}) => {
|
||||
color: var(--van-text-color);
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.van-tab__pane {
|
||||
width: auto;
|
||||
margin: 20px;
|
||||
background-color: var(--van-background-color-light);
|
||||
border-radius: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -64,7 +64,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-tabs__content">
|
||||
<div id="van-tab"
|
||||
role="tabpanel"
|
||||
class="van-tab__panel"
|
||||
class="van-tab__panel demo-icon-tab-panel"
|
||||
tabindex="0"
|
||||
aria-labelledby="van-tabs-0"
|
||||
style
|
||||
@ -88,20 +88,20 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div class="van-row">
|
||||
<div class="van-col van-col--6">
|
||||
<i class="van-badge__wrapper van-icon van-icon-chat-o">
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
</i>
|
||||
</div>
|
||||
<div class="van-col van-col--6">
|
||||
<i class="van-badge__wrapper van-icon van-icon-chat-o">
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
9
|
||||
</div>
|
||||
</i>
|
||||
</div>
|
||||
<div class="van-col van-col--6">
|
||||
<i class="van-badge__wrapper van-icon van-icon-chat-o">
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
99+
|
||||
</div>
|
||||
</i>
|
||||
@ -143,7 +143,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
<div id="van-tab"
|
||||
role="tabpanel"
|
||||
class="van-tab__panel"
|
||||
class="van-tab__panel demo-icon-tab-panel"
|
||||
tabindex="-1"
|
||||
aria-labelledby="van-tabs-1"
|
||||
style="display: none;"
|
||||
@ -151,7 +151,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
<div id="van-tab"
|
||||
role="tabpanel"
|
||||
class="van-tab__panel"
|
||||
class="van-tab__panel demo-icon-tab-panel"
|
||||
tabindex="-1"
|
||||
aria-labelledby="van-tabs-2"
|
||||
style="display: none;"
|
||||
@ -159,7 +159,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
</div>
|
||||
<div id="van-tab"
|
||||
role="tabpanel"
|
||||
class="van-tab__panel"
|
||||
class="van-tab__panel demo-icon-tab-panel"
|
||||
tabindex="-1"
|
||||
aria-labelledby="van-tabs-3"
|
||||
style="display: none;"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should render badge correctly 1`] = `
|
||||
<div class="van-badge van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--fixed">
|
||||
1
|
||||
</div>
|
||||
`;
|
||||
@ -13,7 +13,7 @@ exports[`should render default slot correctly 1`] = `
|
||||
`;
|
||||
|
||||
exports[`should render dot correctly 1`] = `
|
||||
<div class="van-badge van-badge--dot van-badge--fixed">
|
||||
<div class="van-badge van-badge--top-right van-badge--dot van-badge--fixed">
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
@ -116,7 +116,7 @@ app.use(Lazyload);
|
||||
| icon-size `v3.0.11` | 加载图标和失败图标的大小 | _number \| string_ | `32px` |
|
||||
| icon-prefix | 图标类名前缀,等同于 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` |
|
||||
|
||||
### 图片填充模式
|
||||
### 图片填充模式
|
||||
|
||||
| 名称 | 含义 |
|
||||
| ---------- | ------------------------------------------------------ |
|
||||
|
@ -41,20 +41,21 @@ Current supported languages:
|
||||
|
||||
| Language | Filename |
|
||||
| ------------------------ | ------------ |
|
||||
| Chinese | zh-CN |
|
||||
| Traditional Chinese (HK) | zh-HK |
|
||||
| Traditional Chinese (TW) | zh-TW |
|
||||
| German | de-DE |
|
||||
| German (formal) | de-DE-formal |
|
||||
| English | en-US |
|
||||
| Spanish (Spain) | es-ES |
|
||||
| French | fr-FR |
|
||||
| Japanese | ja-JP |
|
||||
| Norwegian | nb-NO |
|
||||
| Portuguese (Brazil) | pt-BR |
|
||||
| Romanian | ro-RO |
|
||||
| Russian | ru-RU |
|
||||
| Turkish | tr-TR |
|
||||
| Thai | th-TH |
|
||||
| French | fr-FR |
|
||||
| Chinese | zh-CN |
|
||||
| Traditional Chinese (HK) | zh-HK |
|
||||
| Traditional Chinese (TW) | zh-TW |
|
||||
|
||||
> View all language configs [Here](https://github.com/youzan/vant/tree/dev/packages/vant/src/locale/lang).
|
||||
|
||||
|
@ -40,22 +40,23 @@ Locale.add(messages);
|
||||
|
||||
目前支持的语言:
|
||||
|
||||
| 语言 | 文件名 |
|
||||
| -------------- | ------------ |
|
||||
| 简体中文 | zh-CN |
|
||||
| 繁體中文(港) | zh-HK |
|
||||
| 繁體中文(台) | zh-TW |
|
||||
| 德语 | de-DE |
|
||||
| 德语 (正式) | de-DE-formal |
|
||||
| 英语 | en-US |
|
||||
| 西班牙语 | es-ES |
|
||||
| 日语 | ja-JP |
|
||||
| 挪威语 | nb-NO |
|
||||
| 罗马尼亚语 | ro-RO |
|
||||
| 俄罗斯语 | ru-RU |
|
||||
| 土耳其语 | tr-TR |
|
||||
| 泰语 | th-TH |
|
||||
| 法语 | fr-FR |
|
||||
| 语言 | 文件名 |
|
||||
| --------------- | ------------ |
|
||||
| 德语 | de-DE |
|
||||
| 德语 (正式) | de-DE-formal |
|
||||
| 英语 | en-US |
|
||||
| 西班牙语 | es-ES |
|
||||
| 法语 | fr-FR |
|
||||
| 日语 | ja-JP |
|
||||
| 挪威语 | nb-NO |
|
||||
| 葡萄牙语 (巴西) | pt-BR |
|
||||
| 罗马尼亚语 | ro-RO |
|
||||
| 俄罗斯语 | ru-RU |
|
||||
| 土耳其语 | tr-TR |
|
||||
| 泰语 | th-TH |
|
||||
| 简体中文 | zh-CN |
|
||||
| 繁體中文(港) | zh-HK |
|
||||
| 繁體中文(台) | zh-TW |
|
||||
|
||||
> 在 [这里](https://github.com/youzan/vant/tree/dev/packages/vant/src/locale/lang) 查看所有的语言包源文件。
|
||||
|
||||
|
72
packages/vant/src/locale/lang/pt-BR.ts
Normal file
72
packages/vant/src/locale/lang/pt-BR.ts
Normal file
@ -0,0 +1,72 @@
|
||||
export default {
|
||||
name: 'Nome',
|
||||
tel: 'Fone',
|
||||
save: 'Salvar',
|
||||
confirm: 'Confirmar',
|
||||
cancel: 'Cancelar',
|
||||
delete: 'Excluir',
|
||||
loading: 'Carregando...',
|
||||
noCoupon: 'Nenhum cupom',
|
||||
nameEmpty: 'Por favor, preencha o nome',
|
||||
telInvalid: 'Telefone em formato inválido',
|
||||
vanCalendar: {
|
||||
end: 'Fim',
|
||||
start: 'Início',
|
||||
title: 'Calendário',
|
||||
startEnd: 'Início/Fim',
|
||||
weekdays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'],
|
||||
monthTitle: (year: number, month: number) => `${month}/${year}`,
|
||||
rangePrompt: (maxRange: number) => `Escolha no máximo ${maxRange} dias`,
|
||||
},
|
||||
vanCascader: {
|
||||
select: 'Selecione',
|
||||
},
|
||||
vanContactCard: {
|
||||
addText: 'Adicionar informações de contato',
|
||||
},
|
||||
vanContactList: {
|
||||
addText: 'Adicionar novo contato',
|
||||
},
|
||||
vanPagination: {
|
||||
prev: 'Anterior',
|
||||
next: 'Próximo',
|
||||
},
|
||||
vanPullRefresh: {
|
||||
pulling: 'Puxe para atualizar...',
|
||||
loosing: 'Solte para atualizar...',
|
||||
},
|
||||
vanSubmitBar: {
|
||||
label: 'Total:',
|
||||
},
|
||||
vanCoupon: {
|
||||
unlimited: 'Ilimitado',
|
||||
discount: (discount: number) => `${discount * 10}% de desconto`,
|
||||
condition: (condition: number) => `Pelo menos ${condition}`,
|
||||
},
|
||||
vanCouponCell: {
|
||||
title: 'Cupom',
|
||||
count: (count: number) => `Você possui ${count} cupom(ns)`,
|
||||
},
|
||||
vanCouponList: {
|
||||
exchange: 'Usar',
|
||||
close: 'Fechar',
|
||||
enable: 'Disponível',
|
||||
disabled: 'Indisponível',
|
||||
placeholder: 'Código do cupom',
|
||||
},
|
||||
vanAddressEdit: {
|
||||
area: 'Área',
|
||||
postal: 'CEP',
|
||||
areaEmpty: 'Por favor, selecione uma área de recebimento',
|
||||
addressEmpty: 'Endereço não pode ser vazio',
|
||||
postalEmpty: 'CEP inválido',
|
||||
defaultAddress: 'Usar como endereço padrão',
|
||||
},
|
||||
vanAddressEditDetail: {
|
||||
label: 'Endereço',
|
||||
placeholder: 'Endereço',
|
||||
},
|
||||
vanAddressList: {
|
||||
add: 'Adicionar novo endereço',
|
||||
},
|
||||
};
|
@ -21,14 +21,17 @@ app.use(NoticeBar);
|
||||
### Basic Usage
|
||||
|
||||
```html
|
||||
<van-notice-bar text="Notice Content" left-icon="volume-o" />
|
||||
<van-notice-bar
|
||||
text="Technology is the common soul of the people who developed it."
|
||||
left-icon="volume-o"
|
||||
/>
|
||||
```
|
||||
|
||||
### Scrollable
|
||||
|
||||
```html
|
||||
<!-- Enable scroll when text is short -->
|
||||
<van-notice-bar scrollable text="Notice Content" />
|
||||
<van-notice-bar scrollable text="Short Content" />
|
||||
|
||||
<!-- Disable scroll when text is long -->
|
||||
<van-notice-bar
|
||||
@ -40,22 +43,24 @@ app.use(NoticeBar);
|
||||
### Wrapable
|
||||
|
||||
```html
|
||||
<van-notice-bar wrapable :scrollable="false">Notice Content</van-notice-bar>
|
||||
<van-notice-bar wrapable :scrollable="false">
|
||||
Technology is the common soul of the people who developed it.
|
||||
</van-notice-bar>
|
||||
```
|
||||
|
||||
### Mode
|
||||
|
||||
```html
|
||||
<van-notice-bar mode="closeable">Notice Content</van-notice-bar>
|
||||
<van-notice-bar mode="closeable">Short Content</van-notice-bar>
|
||||
|
||||
<van-notice-bar mode="link">Notice Content</van-notice-bar>
|
||||
<van-notice-bar mode="link">Short Content</van-notice-bar>
|
||||
```
|
||||
|
||||
### Custom Style
|
||||
|
||||
```html
|
||||
<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
|
||||
Notice Content
|
||||
Short Content
|
||||
</van-notice-bar>
|
||||
```
|
||||
|
||||
|
@ -25,7 +25,7 @@ app.use(NoticeBar);
|
||||
```html
|
||||
<van-notice-bar
|
||||
left-icon="volume-o"
|
||||
text="在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。"
|
||||
text="无论我们能活多久,我们能够享受的只有无法分割的此刻,此外别无其他。"
|
||||
/>
|
||||
```
|
||||
|
||||
@ -35,12 +35,12 @@ app.use(NoticeBar);
|
||||
|
||||
```html
|
||||
<!-- 文字较短时,通过设置 scrollable 属性开启滚动播放 -->
|
||||
<van-notice-bar scrollable text="技术是开发它的人的共同灵魂。" />
|
||||
<van-notice-bar scrollable text="米袋虽空——樱花开哉!" />
|
||||
|
||||
<!-- 文字较长时,通过禁用 scrollable 属性关闭滚动播放 -->
|
||||
<van-notice-bar
|
||||
:scrollable="false"
|
||||
text="在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。"
|
||||
text="不会回头的东西有四件:说出口的话、离弦的箭、逝去的生活和失去的机会。"
|
||||
/>
|
||||
```
|
||||
|
||||
@ -52,7 +52,7 @@ app.use(NoticeBar);
|
||||
<van-notice-bar
|
||||
wrapable
|
||||
:scrollable="false"
|
||||
text="在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。"
|
||||
text="不会回头的东西有四件:说出口的话、离弦的箭、逝去的生活和失去的机会。"
|
||||
/>
|
||||
```
|
||||
|
||||
@ -62,10 +62,10 @@ app.use(NoticeBar);
|
||||
|
||||
```html
|
||||
<!-- closeable 模式,在右侧显示关闭按钮 -->
|
||||
<van-notice-bar mode="closeable">技术是开发它的人的共同灵魂。</van-notice-bar>
|
||||
<van-notice-bar mode="closeable">米袋虽空——樱花开哉!</van-notice-bar>
|
||||
|
||||
<!-- link 模式,在右侧显示链接箭头 -->
|
||||
<van-notice-bar mode="link">技术是开发它的人的共同灵魂。</van-notice-bar>
|
||||
<van-notice-bar mode="link">米袋虽空——樱花开哉!</van-notice-bar>
|
||||
```
|
||||
|
||||
### 自定义样式
|
||||
@ -74,13 +74,13 @@ app.use(NoticeBar);
|
||||
|
||||
```html
|
||||
<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
|
||||
技术是开发它的人的共同灵魂。
|
||||
米袋虽空——樱花开哉!
|
||||
</van-notice-bar>
|
||||
```
|
||||
|
||||
### 垂直滚动
|
||||
|
||||
搭配 NoticeBar 和 Swipe 组件可以实现垂直滚动的效果。
|
||||
搭配 NoticeBar 和 Swipe 组件,可以实现垂直滚动的效果。
|
||||
|
||||
```html
|
||||
<van-notice-bar left-icon="volume-o" :scrollable="false">
|
||||
@ -90,9 +90,9 @@ app.use(NoticeBar);
|
||||
:autoplay="3000"
|
||||
:show-indicators="false"
|
||||
>
|
||||
<van-swipe-item>内容 1</van-swipe-item>
|
||||
<van-swipe-item>内容 2</van-swipe-item>
|
||||
<van-swipe-item>内容 3</van-swipe-item>
|
||||
<van-swipe-item>明月直入,无心可猜。</van-swipe-item>
|
||||
<van-swipe-item>仙人抚我顶,结发受长生。</van-swipe-item>
|
||||
<van-swipe-item>今人不见古时月,今月曾经照古人。</van-swipe-item>
|
||||
</van-swipe>
|
||||
</van-notice-bar>
|
||||
|
||||
|
@ -6,21 +6,28 @@ import { useTranslate } from '../../../docs/site/use-translate';
|
||||
|
||||
const t = useTranslate({
|
||||
'zh-CN': {
|
||||
text: '在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。',
|
||||
mode: '通知栏模式',
|
||||
content: '内容',
|
||||
text1: '无论我们能活多久,我们能够享受的只有无法分割的此刻,此外别无其他。',
|
||||
text2:
|
||||
'不会回头的东西有四件:说出口的话、离弦的箭、逝去的生活和失去的机会。',
|
||||
haiku: '米袋虽空——樱花开哉!',
|
||||
poetry1: '明月直入,无心可猜。',
|
||||
poetry2: '仙人抚我顶,结发受长生。',
|
||||
poetry3: '今人不见古时月,今月曾经照古人。',
|
||||
wrapable: '多行展示',
|
||||
shortText: '技术是开发它的人的共同灵魂。',
|
||||
scrollable: '滚动播放',
|
||||
customStyle: '自定义样式',
|
||||
verticalScroll: '垂直滚动',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Technology is the common soul of the people who developed it.',
|
||||
mode: 'Mode',
|
||||
content: 'Content',
|
||||
text1: 'Technology is the common soul of the people who developed it.',
|
||||
text2: 'Technology is the common soul of the people who developed it.',
|
||||
haiku: 'Short Content',
|
||||
poetry1: 'Content 1',
|
||||
poetry2: 'Content 2',
|
||||
poetry3: 'Content 3',
|
||||
wrapable: 'Wrapable',
|
||||
shortText: 'Some short text.',
|
||||
customStyle: 'Custom Style',
|
||||
scrollable: 'Scrollable',
|
||||
verticalScroll: 'Vertical Scroll',
|
||||
@ -30,26 +37,26 @@ const t = useTranslate({
|
||||
|
||||
<template>
|
||||
<demo-block :title="t('basicUsage')">
|
||||
<van-notice-bar :text="t('text')" scrollable left-icon="volume-o" />
|
||||
<van-notice-bar :text="t('text1')" scrollable left-icon="volume-o" />
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('scrollable')">
|
||||
<van-notice-bar scrollable :text="t('shortText')" />
|
||||
<van-notice-bar :scrollable="false" :text="t('text')" />
|
||||
<van-notice-bar scrollable :text="t('haiku')" />
|
||||
<van-notice-bar :scrollable="false" :text="t('text2')" />
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('wrapable')">
|
||||
<van-notice-bar wrapable :scrollable="false" :text="t('text')" />
|
||||
<van-notice-bar wrapable :scrollable="false" :text="t('text2')" />
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('mode')">
|
||||
<van-notice-bar mode="closeable" :text="t('shortText')" />
|
||||
<van-notice-bar mode="link" :text="t('shortText')" />
|
||||
<van-notice-bar mode="closeable" :text="t('haiku')" />
|
||||
<van-notice-bar mode="link" :text="t('haiku')" />
|
||||
</demo-block>
|
||||
|
||||
<demo-block :title="t('customStyle')">
|
||||
<van-notice-bar
|
||||
:text="t('shortText')"
|
||||
:text="t('haiku')"
|
||||
color="#1989fa"
|
||||
background="#ecf9ff"
|
||||
left-icon="info-o"
|
||||
@ -64,9 +71,9 @@ const t = useTranslate({
|
||||
:autoplay="3000"
|
||||
:show-indicators="false"
|
||||
>
|
||||
<van-swipe-item>{{ t('content') }} 1</van-swipe-item>
|
||||
<van-swipe-item>{{ t('content') }} 2</van-swipe-item>
|
||||
<van-swipe-item>{{ t('content') }} 3</van-swipe-item>
|
||||
<van-swipe-item>{{ t('poetry1') }}</van-swipe-item>
|
||||
<van-swipe-item>{{ t('poetry2') }}</van-swipe-item>
|
||||
<van-swipe-item>{{ t('poetry3') }}</van-swipe-item>
|
||||
</van-swipe>
|
||||
</van-notice-bar>
|
||||
</demo-block>
|
||||
|
@ -28,7 +28,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div style="transition-duration: 0s;"
|
||||
class="van-notice-bar__content"
|
||||
>
|
||||
Some short text.
|
||||
Short Content
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -71,7 +71,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div style="transition-duration: 0s;"
|
||||
class="van-notice-bar__content"
|
||||
>
|
||||
Some short text.
|
||||
Short Content
|
||||
</div>
|
||||
</div>
|
||||
<i class="van-badge__wrapper van-icon van-icon-cross van-notice-bar__right-icon">
|
||||
@ -86,7 +86,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div style="transition-duration: 0s;"
|
||||
class="van-notice-bar__content"
|
||||
>
|
||||
Some short text.
|
||||
Short Content
|
||||
</div>
|
||||
</div>
|
||||
<i class="van-badge__wrapper van-icon van-icon-arrow van-notice-bar__right-icon">
|
||||
@ -106,7 +106,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
<div style="transition-duration: 0s;"
|
||||
class="van-notice-bar__content"
|
||||
>
|
||||
Some short text.
|
||||
Short Content
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -107,7 +107,7 @@ export default {
|
||||
|
||||
| Attribute | Description | Type | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| type | Can be set to `primary` `success` `warning` | _string_ | `danger` |
|
||||
| type | Can be set to `primary` `success` `warning` | _NotifyType_ | `danger` |
|
||||
| message | Message | _string_ | - |
|
||||
| duration | Duration(ms), won't disappear if value is 0 | _number \| string_ | `3000` |
|
||||
| color | Message color | _string_ | `white` |
|
||||
|
@ -155,7 +155,7 @@ export default {
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| type | 类型,可选值为 `primary` `success` `warning` | _string_ | `danger` |
|
||||
| type | 类型,可选值为 `primary` `success` `warning` | _NotifyType_ | `danger` |
|
||||
| message | 展示文案,支持通过`\n`换行 | _string_ | - |
|
||||
| duration | 展示时长(ms),值为 0 时,notify 不会消失 | _number \| string_ | `3000` |
|
||||
| color | 字体颜色 | _string_ | `white` |
|
||||
|
@ -190,7 +190,7 @@ export default {
|
||||
|
||||
| Event | Description | Arguments |
|
||||
| --- | --- | --- |
|
||||
| input | Emitted when a key is pressed | key: Content of the key |
|
||||
| input | Emitted when a key is pressed | _key: string_ |
|
||||
| delete | Emitted when the delete key is pressed | - |
|
||||
| close | Emitted when the close button is clicked | - |
|
||||
| blur | Emitted when the close button is clicked or the keyboard is blurred | - |
|
||||
|
@ -197,7 +197,7 @@ export default {
|
||||
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
| ------ | ------------------------------ | ------------- |
|
||||
| input | 点击按键时触发 | key: 按键内容 |
|
||||
| input | 点击按键时触发 | _key: string_ |
|
||||
| delete | 点击删除键时触发 | - |
|
||||
| close | 点击关闭按钮时触发 | - |
|
||||
| blur | 点击关闭按钮或非键盘区域时触发 | - |
|
||||
|
@ -133,8 +133,9 @@ export default defineComponent({
|
||||
]}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
onClick={() => updateModelValue(modelValue - 1)}
|
||||
onClick={() => updateModelValue(modelValue - 1, true)}
|
||||
>
|
||||
{slot ? slot() : props.prevText || t('prev')}
|
||||
</button>
|
||||
@ -154,8 +155,9 @@ export default defineComponent({
|
||||
]}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
onClick={() => updateModelValue(modelValue + 1)}
|
||||
onClick={() => updateModelValue(modelValue + 1, true)}
|
||||
>
|
||||
{slot ? slot() : props.nextText || t('next')}
|
||||
</button>
|
||||
@ -172,8 +174,9 @@ export default defineComponent({
|
||||
]}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-current={page.active || undefined}
|
||||
onClick={() => updateModelValue(page.number)}
|
||||
onClick={() => updateModelValue(page.number, true)}
|
||||
>
|
||||
{slots.page ? slots.page(page) : page.text}
|
||||
</button>
|
||||
|
@ -39,7 +39,7 @@ export default {
|
||||
|
||||
### 简单模式
|
||||
|
||||
将 `mode` 设置为 `simple` 来切换到简单模式,此时分页器不会展示具体的页码按钮。
|
||||
将 `mode` 设置为 `simple` 来切换到简单模式,此时分页器不会展示具体的页码按钮。
|
||||
|
||||
```html
|
||||
<van-pagination v-model="currentPage" :page-count="12" mode="simple" />
|
||||
|
@ -7,37 +7,41 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--disabled van-pagination__item--prev van-hairline--surround">
|
||||
<button disabled>
|
||||
<button type="button"
|
||||
disabled
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--active van-pagination__item--page van-hairline--surround">
|
||||
<button aria-current="true">
|
||||
<button type="button"
|
||||
aria-current="true"
|
||||
>
|
||||
1
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
2
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
3
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
4
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
5
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Next
|
||||
</button>
|
||||
</li>
|
||||
@ -51,7 +55,9 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--disabled van-pagination__item--border van-pagination__item--prev van-hairline--surround">
|
||||
<button disabled>
|
||||
<button type="button"
|
||||
disabled
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
</li>
|
||||
@ -59,7 +65,7 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
1/12
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--border van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Next
|
||||
</button>
|
||||
</li>
|
||||
@ -72,32 +78,36 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--disabled van-pagination__item--prev van-hairline--surround">
|
||||
<button disabled>
|
||||
<button type="button"
|
||||
disabled
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--active van-pagination__item--page van-hairline--surround">
|
||||
<button aria-current="true">
|
||||
<button type="button"
|
||||
aria-current="true"
|
||||
>
|
||||
1
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
2
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
3
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
...
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Next
|
||||
</button>
|
||||
</li>
|
||||
@ -110,38 +120,42 @@ exports[`should render demo and match snapshot 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--disabled van-pagination__item--prev van-hairline--surround">
|
||||
<button disabled>
|
||||
<button type="button"
|
||||
disabled
|
||||
>
|
||||
<i class="van-badge__wrapper van-icon van-icon-arrow-left">
|
||||
</i>
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--active van-pagination__item--page van-hairline--surround">
|
||||
<button aria-current="true">
|
||||
<button type="button"
|
||||
aria-current="true"
|
||||
>
|
||||
1
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
2
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
3
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
4
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
5
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
<i class="van-badge__wrapper van-icon van-icon-arrow">
|
||||
</i>
|
||||
</button>
|
||||
|
@ -6,37 +6,37 @@ exports[`should render page slot correctly 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--prev van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Previous
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
foo 1
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
foo 2
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
foo 3
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
foo 4
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
foo 5
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Next
|
||||
</button>
|
||||
</li>
|
||||
@ -50,37 +50,37 @@ exports[`should render prev-text、next-text slot correctly 1`] = `
|
||||
>
|
||||
<ul class="van-pagination__items">
|
||||
<li class="van-pagination__item van-pagination__item--prev van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Custom PrevText
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
1
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
2
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
3
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
4
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--page van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
5
|
||||
</button>
|
||||
</li>
|
||||
<li class="van-pagination__item van-pagination__item--next van-hairline--surround">
|
||||
<button>
|
||||
<button type="button">
|
||||
Custom NextText
|
||||
</button>
|
||||
</li>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user