types: improve ref typing (#8182)

This commit is contained in:
neverland
2021-02-19 20:58:02 +08:00
committed by GitHub
parent 7daca89102
commit 9ad0eafae0
9 changed files with 31 additions and 20 deletions
+3 -3
View File
@@ -55,8 +55,8 @@ export default createComponent({
setup(props, { emit }) {
const [visible, setVisible] = useToggle();
const daysRef = ref();
const monthRef = ref();
const daysRef = ref<HTMLElement>();
const monthRef = ref<HTMLElement>();
const height = useHeight(monthRef);
const title = computed(() => formatMonthTitle(props.date));
@@ -82,7 +82,7 @@ export default createComponent({
const el = props.showSubtitle ? daysRef.value : monthRef.value;
const scrollTop =
el.getBoundingClientRect().top -
el!.getBoundingClientRect().top -
body.getBoundingClientRect().top +
body.scrollTop;
+2 -2
View File
@@ -174,7 +174,7 @@ export default createComponent({
let bodyHeight: number;
const bodyRef = ref();
const bodyRef = ref<HTMLElement>();
const state = reactive({
subtitle: '',
@@ -219,7 +219,7 @@ export default createComponent({
// calculate the position of the elements
// and find the elements that needs to be rendered
const onScroll = () => {
const top = getScrollTop(bodyRef.value);
const top = getScrollTop(bodyRef.value!);
const bottom = top + bodyHeight;
const heights = months.value.map((item, index) =>