1234567891011121314151617181920212223242526272829 |
- <template>
- <div>
- <slot></slot>
- </div>
- </template>
- <script>
- export default {
- name: "teleport",
- props: {
- to: {
- type: String,
- required: true,
- },
- },
- mounted() {
- const toEl = document.querySelector(this.to);
- if (toEl) {
- toEl.appendChild(this.$el);
- }
- },
- destroyed() {
- const toEl = document.querySelector(this.to);
- if (toEl) {
- toEl.removeChild(this.$el);
- }
- },
- };
- </script>
|