Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(calendar): 日历组件(V4)添加自定义方法 #2084

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/packages/__VUE/calendar/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ Through [ref](https://vuejs.org/guide/essentials/template-refs.html), you can ge
| Name | Description | Arguments |
|--------|------------------|---------------|
| scrollToDate | Scroll to the month of the specified date:'2021-12-30' | `string` |
| initPosition `v4.0.1` | Initialize scroll position | |
## Theming

### CSS Variables
Expand Down
1 change: 1 addition & 0 deletions src/packages/__VUE/calendar/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ export default {
| 方法名 | 说明 | 参数 |
|----------------|-------------------|---------------|
| scrollToDate | 滚动到指定日期所在月,如:'2021-12-30' | `string` |
| initPosition `v4.0.1` | 初始化滚动位置 | 无 |

## 主题定制

Expand Down
2 changes: 1 addition & 1 deletion src/packages/__VUE/calendar/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ export default {
| 方法名 | 说明 | 参数 |
|--------|------------------|---------------|
| scrollToDate | 滚动到指定日期所在月,如:'2021-12-30' | `string` |

| initPosition `v4.0.1` | 初始化滚动位置 | 无 |
## 主题定制

### 样式变量
Expand Down
6 changes: 5 additions & 1 deletion src/packages/__VUE/calendar/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ export default create({
const scrollToDate = (date: string) => {
calendarRef.value?.scrollToDate(date);
};
const initPosition = () => {
calendarRef.value?.initPosition();
};
useExpose({
scrollToDate
scrollToDate,
initPosition
});
// methods
const update = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/packages/__VUE/calendar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ export default create({
const scrollToDate = (date: string) => {
calendarRef.value?.scrollToDate(date);
};
const initPosition = () => {
calendarRef.value?.initPosition();
};
useExpose({
scrollToDate
scrollToDate,
initPosition
});
// methods
const update = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/packages/__VUE/calendaritem/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,12 @@ export default create({
}
});
};
const initPosition = () => {
state.scrollTop = Math.ceil(state.monthsData[state.currentIndex].cssScrollHeight);
};
useExpose({
scrollToDate
scrollToDate,
initPosition
});
const setDefaultRange = (monthsNum: number, current: number) => {
let rangeArr: number[] = [];
Expand Down
8 changes: 7 additions & 1 deletion src/packages/__VUE/calendaritem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,14 @@ export default create({
}
});
};
const initPosition = () => {
if (months?.value) {
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
}
};
useExpose({
scrollToDate
scrollToDate,
initPosition
});
// 设置当前可见月份
const setDefaultRange = (monthsNum: number, current: number) => {
Expand Down
1 change: 1 addition & 0 deletions src/packages/__VUE/calendaritem/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ export interface MonthInfo {
}
export interface CalendarRef extends HTMLElement {
scrollToDate: (date: string) => void;
initPosition: () => void;
}