页面
<template>
<view>
<view class="pt-200px h-11000">
<button @click="popupRef.open()">打开</button>
</view>
<test ref="popupRef">
<view class="bg-#fff p-20rpx">
<input type="text" value="12" />
</view>
</test>
</view>
</template>
<script setup lang="ts">
import test from "./test.vue";
const popupRef = ref();
</script>
子组件
<template>
<view class="fixed inset-0 z-9997" v-if="show">
<view class="fixed inset-0 z-9998 bg-(#000 opacity-40)" @click="close"> </view>
<view class="fixed left-0 bottom-300px w-100% z-9999">
<slot></slot>
</view>
</view>
</template>
<script setup lang="ts">
//组件
//方法
//接口
//仓库
//
defineOptions({
virtualHost: true,
});
const show = ref(false);
const open = () => {
show.value = true;
};
const close = () => {
show.value = false;
};
defineExpose({
open,
close,
});
</script>
<style scoped lang="scss"></style>