first commit
This commit is contained in:
39
node_modules/vant/es/utils/mount-component.mjs
generated
vendored
Normal file
39
node_modules/vant/es/utils/mount-component.mjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { createApp, reactive } from "vue";
|
||||
import { extend } from "./basic.mjs";
|
||||
import { useExpose } from "../composables/use-expose.mjs";
|
||||
function usePopupState() {
|
||||
const state = reactive({
|
||||
show: false
|
||||
});
|
||||
const toggle = (show) => {
|
||||
state.show = show;
|
||||
};
|
||||
const open = (props) => {
|
||||
extend(state, props, { transitionAppear: true });
|
||||
toggle(true);
|
||||
};
|
||||
const close = () => toggle(false);
|
||||
useExpose({ open, close, toggle });
|
||||
return {
|
||||
open,
|
||||
close,
|
||||
state,
|
||||
toggle
|
||||
};
|
||||
}
|
||||
function mountComponent(RootComponent) {
|
||||
const app = createApp(RootComponent);
|
||||
const root = document.createElement("div");
|
||||
document.body.appendChild(root);
|
||||
return {
|
||||
instance: app.mount(root),
|
||||
unmount() {
|
||||
app.unmount();
|
||||
document.body.removeChild(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
mountComponent,
|
||||
usePopupState
|
||||
};
|
||||
Reference in New Issue
Block a user