types: improve ref typing (#8124)

* types: improve ref typing

* types: message
This commit is contained in:
neverland 2021-02-10 20:57:24 +08:00 committed by GitHub
parent 3e08b2471a
commit 0b68d3a141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 10 deletions

View File

@ -1,8 +1,8 @@
import { useRect } from '@vant/use';
import { Ref, ref, onMounted, nextTick } from 'vue';
export const useHeight = (element: Element | Ref<Element>) => {
const height = ref();
export const useHeight = (element: Element | Ref<Element | undefined>) => {
const height = ref<number>();
onMounted(() => {
nextTick(() => {

View File

@ -2,7 +2,7 @@ import { useHeight } from './use-height';
import type { Ref } from 'vue';
import type { BEM } from '../utils/create/bem';
export function usePlaceholder(contentRef: Ref<Element>, bem: BEM) {
export function usePlaceholder(contentRef: Ref<Element | undefined>, bem: BEM) {
const height = useHeight(contentRef);
return (renderContent: () => JSX.Element) => (

View File

@ -31,7 +31,7 @@ export default createComponent({
emits: ['click-left', 'click-right'],
setup(props, { emit, slots }) {
const navBarRef = ref();
const navBarRef = ref<HTMLElement>();
const renderPlaceholder = usePlaceholder(navBarRef, bem);
const onClickLeft = (event: MouseEvent) => {

View File

@ -46,8 +46,8 @@ export default createComponent({
let contentWidth = 0;
let startTimer: NodeJS.Timeout;
const wrapRef = ref();
const contentRef = ref();
const wrapRef = ref<HTMLElement>();
const contentRef = ref<HTMLElement>();
const state = reactive({
show: true,

View File

@ -112,7 +112,7 @@ export default createComponent({
let shouldReopen: boolean;
const zIndex = ref<number>();
const popupRef = ref();
const popupRef = ref<HTMLElement>();
const [lockScroll, unlockScroll] = useLockScroll(
popupRef,

View File

@ -52,7 +52,7 @@ export default createComponent({
setup(props, { emit, slots }) {
let reachTop: boolean;
const root = ref();
const root = ref<HTMLElement>();
const scrollParent = useScrollParent(root);
const state = reactive({

View File

@ -127,7 +127,7 @@ export default createComponent({
};
let actionType: 'plus' | 'minus';
const inputRef = ref();
const inputRef = ref<HTMLInputElement>();
const current = ref(getInitialValue());
const minusDisabled = computed(

View File

@ -65,7 +65,7 @@ function parseOptions(message: string | ToastOptions): ToastOptions {
function createInstance() {
const { instance, unmount } = mountComponent({
setup() {
const message = ref();
const message = ref('');
const { open, state, close, toggle } = usePopupState();
const onClosed = () => {