Compare commits

...

4 Commits

Author SHA1 Message Date
neverland
839bcd8928
docs: add unplugin-vue-components tip (#11251) 2022-11-13 10:46:49 +08:00
neverland
1f917e9a2a
fix(Picker): empty column will cause error (#11249) 2022-11-13 10:26:41 +08:00
neverland
83dcbe6f5f
fix(DatePicker): only throw error in development (#11248) 2022-11-13 09:22:48 +08:00
neverland
e6c6265e69
fix(Skeleton): incorrect export component name (#11247)
* fix(Skeleton): incorrect export component name

* chore: fix name
2022-11-13 09:21:05 +08:00
9 changed files with 45 additions and 24 deletions

View File

@ -213,6 +213,11 @@ import 'vant/es/image-preview/style';
> Tip: "Full Import" and "On-demand Import" should not be used at the same time, otherwise it will lead to problems such as code duplication and style overrides.
#### Tips
- "Full Import" and "On-demand Import" should not be used at the same time, otherwise it will lead to problems such as code duplication and style overrides.
- unplugin-vue-components is not officially maintained by Vant. If you encounter issues when using this plugin, please feedback to [antfu/unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) repository.
## With Frameworks
### Use Vant in Nuxt 3

View File

@ -218,7 +218,10 @@ import 'vant/es/image-preview/style';
你可以在项目的入口文件或公共模块中引入以上组件的样式,这样在业务代码中使用组件时,便不再需要重复引入样式了。
> 提示:在单个项目中不应该同时使用「全量引入」和「按需引入」,否则会导致代码重复、样式错乱等问题。
#### 使用提示
- 请避免同时使用「全量引入」和「按需引入」这两种引入方式,否则会导致代码重复、样式错乱等问题。
- unplugin-vue-components 并不是 Vant 官方维护的插件,如果在使用过程中遇到问题,建议优先到 [antfu/unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) 仓库下反馈。
## 在框架中使用

View File

@ -128,9 +128,12 @@ export default defineComponent({
case 'day':
return genDayOptions();
default:
throw new Error(
`[Vant] DatePicker: unsupported columns type: ${type}`
);
if (process.env.NODE_ENV !== 'production') {
throw new Error(
`[Vant] DatePicker: unsupported columns type: ${type}`
);
}
return [];
}
})
);

View File

@ -195,6 +195,8 @@ export default defineComponent({
const { offsetX, offsetY } = touch;
const deltaTime = Date.now() - touchStartTime;
// Same as the default value of iOS double tap timeout
const TAP_TIME = 250;
const TAP_OFFSET = 5;

View File

@ -97,8 +97,10 @@ export default defineComponent({
currentOffset.value = offset;
};
const isReadonly = () => props.readonly || !props.options.length;
const onClickOption = (index: number) => {
if (moving || props.readonly) {
if (moving || isReadonly()) {
return;
}
@ -134,7 +136,7 @@ export default defineComponent({
};
const onTouchStart = (event: TouchEvent) => {
if (props.readonly) {
if (isReadonly()) {
return;
}
@ -153,7 +155,7 @@ export default defineComponent({
};
const onTouchMove = (event: TouchEvent) => {
if (props.readonly) {
if (isReadonly()) {
return;
}
@ -178,7 +180,7 @@ export default defineComponent({
};
const onTouchEnd = () => {
if (props.readonly) {
if (isReadonly()) {
return;
}

View File

@ -1,5 +1,8 @@
<script setup lang="ts">
import VanSkeleton, { VanSkeletonParagraph, VanSkeletonImage } from '..';
import VanSkeleton, {
SkeletonImage as VanSkeletonImage,
SkeletonParagraph as VanSkeletonParagraph,
} from '..';
import VanSwitch from '../../switch';
import { ref } from 'vue';
import { cdnURL, useTranslate } from '../../../docs/site';

View File

@ -6,10 +6,10 @@ import _SkeletonParagraph from './SkeletonParagraph';
import { withInstall } from '../utils';
export const VanSkeletonImage = withInstall(_SkeletonImage);
export const VanSkeletonTitle = withInstall(_SkeletonTitle);
export const VanSkeletonAvatar = withInstall(_SkeletonAvatar);
export const VanSkeletonParagraph = withInstall(_SkeletonParagraph);
export const SkeletonImage = withInstall(_SkeletonImage);
export const SkeletonTitle = withInstall(_SkeletonTitle);
export const SkeletonAvatar = withInstall(_SkeletonAvatar);
export const SkeletonParagraph = withInstall(_SkeletonParagraph);
export const Skeleton = withInstall(_Skeleton);
export default Skeleton;
@ -43,9 +43,9 @@ export type {
declare module 'vue' {
export interface GlobalComponents {
VanSkeleton: typeof Skeleton;
VanSkeletonImage: typeof VanSkeletonImage;
VanSkeletonTitle: typeof VanSkeletonTitle;
VanSkeletonAvatar: typeof VanSkeletonAvatar;
VanSkeletonParagraph: typeof VanSkeletonParagraph;
VanSkeletonImage: typeof SkeletonImage;
VanSkeletonTitle: typeof SkeletonTitle;
VanSkeletonAvatar: typeof SkeletonAvatar;
VanSkeletonParagraph: typeof SkeletonParagraph;
}
}

View File

@ -1,5 +1,5 @@
import { mount } from '../../../test';
import { Skeleton, VanSkeletonImage } from '..';
import { Skeleton, SkeletonImage } from '..';
test('should render with row width array correctly', () => {
const wrapper = mount(Skeleton, {
@ -80,13 +80,13 @@ test('should allow to disable animation', async () => {
});
test('should skeleton image render correctly', () => {
const wrapper = mount(VanSkeletonImage);
const wrapper = mount(SkeletonImage);
expect(wrapper.html()).toMatchSnapshot();
});
test('should skeleton image works with imageSize prop', () => {
const wrapper = mount(VanSkeletonImage, {
const wrapper = mount(SkeletonImage, {
props: {
imageSize: '20rem',
},
@ -98,7 +98,7 @@ test('should skeleton image works with imageSize prop', () => {
});
test('should skeleton image works with imageShape prop', () => {
const wrapper = mount(VanSkeletonImage, {
const wrapper = mount(SkeletonImage, {
props: {
imageShape: 'round',
},

View File

@ -83,9 +83,12 @@ export default defineComponent({
filter
);
default:
throw new Error(
`[Vant] DatePicker: unsupported columns type: ${type}`
);
if (process.env.NODE_ENV !== 'production') {
throw new Error(
`[Vant] DatePicker: unsupported columns type: ${type}`
);
}
return [];
}
})
);