Responsive issues with Vue3 imperative components #12339
Answered
by
Wei-Ba
xhc-code
asked this question in
Help/Questions
Replies: 2 comments 22 replies
-
// - const vnode = createVNode('span', null, count.value.toString());
const vnode = h('span', null, h(() => count.value)) // h === createVNode |
Beta Was this translation helpful? Give feedback.
20 replies
Answer selected by
xhc-code
-
为了方便起见,这里贴上大致得代码。 <script setup>
const props = defineProps({
visible: {
type: Boolean,
required: true
}
})
</script> import LoadingComponent from './Loading.vue';
import {createVNode, h, nextTick, ref, render} from "vue";
export function useLoading(){
let container = document.createElement('div');
const visible = ref(false);
const vNode = createVNode(()=>{
return createVNode(LoadingComponent, {
visible: visible.value,
});
});
render(vNode, container);
document.body.appendChild(container.firstElementChild);
visible.value = true;
setTimeout(()=>{
visible.value = false;
render(null, container);
container = null;
console.log("关闭显示", visible)
}, 10000);
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Why isn't the span content of this command based component updated? Not responsive, but count is responsive.
Beta Was this translation helpful? Give feedback.
All reactions