mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-29 09:49:16 +08:00
types: improve ref typing (#8124)
* types: improve ref typing * types: message
This commit is contained in:
parent
3e08b2471a
commit
0b68d3a141
@ -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(() => {
|
||||
|
@ -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) => (
|
||||
|
@ -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) => {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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({
|
||||
|
@ -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(
|
||||
|
@ -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 = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user