比如剪切板,现在是这样做的:
import component from './clipboard';
import { createApp } from 'vue';
let instance,
copyText;
const createInstance = () => {
const element = window.document.createElement('div');
element.style.display = 'none';
window.document.body.appendChild(element);
instance = createApp(component).mount(element);
copyText = instance.copyText;
};
const install = (app) => {
if (!instance) createInstance();
app.config.globalProperties.$copyText = copyText;
};
export default {
install,
copyText,
};
想知道你们是怎么做的。