mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-04 04:42:09 +08:00 
			
		
		
		
	Merge branch '2.x' into dev
This commit is contained in:
		
						commit
						3a0b6d1c30
					
				@ -335,8 +335,9 @@ Following props are supported when the type is multiple
 | 
			
		||||
Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get Calendar instance and call instance methods.
 | 
			
		||||
 | 
			
		||||
| Name | Description | Attribute | Return value |
 | 
			
		||||
| ----- | ----------------------------------- | --------- | ------------ |
 | 
			
		||||
| --- | --- | --- | --- |
 | 
			
		||||
| reset | Reset selected date to default date | - | - |
 | 
			
		||||
| scrollToDate `v2.12.2` | Scroll to date | _date: Date_ | - |
 | 
			
		||||
 | 
			
		||||
### Less Variables
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -341,8 +341,9 @@ export default {
 | 
			
		||||
通过 ref 可以获取到 Calendar 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。
 | 
			
		||||
 | 
			
		||||
| 方法名                 | 说明                   | 参数         | 返回值 |
 | 
			
		||||
| ------ | ---------------------- | ---- | ------ |
 | 
			
		||||
| ---------------------- | ---------------------- | ------------ | ------ |
 | 
			
		||||
| reset                  | 重置选中的日期到默认值 | -            | -      |
 | 
			
		||||
| scrollToDate `v2.12.2` | 滚动到某个日期         | _date: Date_ | -      |
 | 
			
		||||
 | 
			
		||||
### 样式变量
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -267,27 +267,8 @@ export default createComponent({
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // scroll to current month
 | 
			
		||||
    const scrollIntoView = () => {
 | 
			
		||||
    const scrollToDate = (targetDate) => {
 | 
			
		||||
      raf(() => {
 | 
			
		||||
        const displayed = props.show || !props.poppable;
 | 
			
		||||
        if (!displayed) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        onScroll();
 | 
			
		||||
 | 
			
		||||
        const { currentDate } = state;
 | 
			
		||||
        if (!currentDate) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const targetDate =
 | 
			
		||||
          props.type === 'single' ? currentDate : currentDate[0];
 | 
			
		||||
        if (!targetDate) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        months.value.some((month, index) => {
 | 
			
		||||
          if (compareMonth(month, targetDate) === 0) {
 | 
			
		||||
            monthRefs.value[index].scrollIntoView(bodyRef.value);
 | 
			
		||||
@ -301,6 +282,22 @@ export default createComponent({
 | 
			
		||||
      });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // scroll to current month
 | 
			
		||||
    const scrollIntoView = () => {
 | 
			
		||||
      if (props.poppable && !props.show) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const { currentDate } = state;
 | 
			
		||||
      if (currentDate) {
 | 
			
		||||
        const targetDate =
 | 
			
		||||
          props.type === 'single' ? currentDate : currentDate[0];
 | 
			
		||||
        scrollToDate(targetDate);
 | 
			
		||||
      } else {
 | 
			
		||||
        raf(onScroll);
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const init = () => {
 | 
			
		||||
      if (props.poppable && !props.show) {
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
@ -102,6 +102,14 @@ export default {
 | 
			
		||||
| ------- | -------------------------------- |
 | 
			
		||||
| default | 锚点位置显示内容,默认为索引字符 |
 | 
			
		||||
 | 
			
		||||
### IndexBar 方法
 | 
			
		||||
 | 
			
		||||
通过 ref 可以获取到 IndexBar 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。
 | 
			
		||||
 | 
			
		||||
| 方法名             | 说明           | 参数                      | 返回值 |
 | 
			
		||||
| ------------------ | -------------- | ------------------------- | ------ |
 | 
			
		||||
| scrollTo `v2.12.2` | 滚动到指定锚点 | _index: number \| string_ | -      |
 | 
			
		||||
 | 
			
		||||
### 样式变量
 | 
			
		||||
 | 
			
		||||
组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考[主题定制](#/zh-CN/theme)。
 | 
			
		||||
 | 
			
		||||
@ -79,7 +79,7 @@ app.use(Loading);
 | 
			
		||||
### Props
 | 
			
		||||
 | 
			
		||||
| 参数       | 说明                          | 类型               | 默认值     |
 | 
			
		||||
| ---------- | ---------------------------- | ------------------ | ---------- |
 | 
			
		||||
| ---------- | ----------------------------- | ------------------ | ---------- |
 | 
			
		||||
| color      | 颜色                          | _string_           | `#c9c9c9`  |
 | 
			
		||||
| type       | 类型,可选值为 `spinner`      | _string_           | `circular` |
 | 
			
		||||
| size       | 加载图标大小,默认单位为 `px` | _number \| string_ | `30px`     |
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								types/calendar.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								types/calendar.d.ts
									
									
									
									
										vendored
									
									
								
							@ -2,4 +2,6 @@ import { VanComponent } from './component';
 | 
			
		||||
 | 
			
		||||
export class Calendar extends VanComponent {
 | 
			
		||||
  reset(): void;
 | 
			
		||||
 | 
			
		||||
  scrollToDate(date: Date): void;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								types/index-bar.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								types/index-bar.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
import { VanComponent } from './component';
 | 
			
		||||
 | 
			
		||||
export class IndexBar extends VanComponent {
 | 
			
		||||
  scrollTo(index: number | string): void;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								types/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								types/index.d.ts
									
									
									
									
										vendored
									
									
								
							@ -14,6 +14,7 @@ import { DropdownItem } from './dropdown-item';
 | 
			
		||||
import { Field } from './field';
 | 
			
		||||
import { Form } from './form';
 | 
			
		||||
import { ImagePreview } from './image-preview';
 | 
			
		||||
import { IndexBar } from './index-bar';
 | 
			
		||||
import { Lazyload } from './lazyload';
 | 
			
		||||
import { List } from './list';
 | 
			
		||||
import { Locale } from './locale';
 | 
			
		||||
@ -59,7 +60,6 @@ export class ActionBarButton extends VanComponent {}
 | 
			
		||||
export class Icon extends VanComponent {}
 | 
			
		||||
export class Image extends VanComponent {}
 | 
			
		||||
export class IndexAnchor extends VanComponent {}
 | 
			
		||||
export class IndexBar extends VanComponent {}
 | 
			
		||||
export class Info extends VanComponent {}
 | 
			
		||||
export class Loading extends VanComponent {}
 | 
			
		||||
export class NavBar extends VanComponent {}
 | 
			
		||||
@ -109,6 +109,7 @@ export {
 | 
			
		||||
  Form,
 | 
			
		||||
  Field,
 | 
			
		||||
  ImagePreview,
 | 
			
		||||
  IndexBar,
 | 
			
		||||
  Lazyload,
 | 
			
		||||
  List,
 | 
			
		||||
  Locale,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user