跳至内容
菜单
此问题已终结
1 回复
1503 查看

UncaughtPromiseError > OwlError

Uncaught Promise > The following error occurred in onMounted: "invalid portal target"

OwlError: The following error occurred in onMounted: "invalid portal target"

    Error

        at wrapError (http://localhost:8069/web/assets/debug/web.assets_web.js:10193:23) (/web/static/lib/owl/owl.js:2609)

        at onMounted (http://localhost:8069/web/assets/debug/web.assets_web.js:10247:27) (/web/static/lib/owl/owl.js:2663)

        at Portal.setup (http://localhost:8069/web/assets/debug/web.assets_web.js:10364:13) (/web/static/lib/owl/owl.js:2780)

        at new ComponentNode (http://localhost:8069/web/assets/debug/web.assets_web.js:9941:28) (/web/static/lib/owl/owl.js:2357)

        at http://localhost:8069/web/assets/debug/web.assets_web.js:13396:28 (/web/static/lib/owl/owl.js:5812)

        at ProductCatalogOrderLine.template (eval at compile (http://localhost:8069/web/assets/debug/web.assets_web.js:13135:20), <anonymous>:26:10) (/web/static/lib/owl/owl.js:5551)

        at Fiber._render (http://localhost:8069/web/assets/debug/web.assets_web.js:9306:38) (/web/static/lib/owl/owl.js:1722)

        at Fiber.render (http://localhost:8069/web/assets/debug/web.assets_web.js:9298:18) (/web/static/lib/owl/owl.js:1714)

        at ComponentNode.initiateRender (http://localhost:8069/web/assets/debug/web.assets_web.js:9963:23) (/web/static/lib/owl/owl.js:2379)


Caused by: OwlError: invalid portal target

    Error: invalid portal target

        at Portal.<anonymous> (http://localhost:8069/web/assets/debug/web.assets_web.js:10372:31) (/web/static/lib/owl/owl.js:2788)

        at http://localhost:8069/web/assets/debug/web.assets_web.js:10207:26 (/web/static/lib/owl/owl.js:2623)

        at RootFiber.complete (http://localhost:8069/web/assets/debug/web.assets_web.js:9355:29) (/web/static/lib/owl/owl.js:1771)

        at Scheduler.processFiber (http://localhost:8069/web/assets/debug/web.assets_web.js:13218:27) (/web/static/lib/owl/owl.js:5634)

        at Scheduler.processTasks (http://localhost:8069/web/assets/debug/web.assets_web.js:13194:22) (/web/static/lib/owl/owl.js:5610)

        at http://localhost:8069/web/assets/debug/web.assets_web.js:13184:68 (/web/static/lib/owl/owl.js:5600)

形象
丢弃
最佳答案

In OWL, portals are used to render components outside the main component hierarchy, often for modals, popups, or tooltips. This error suggests that the target DOM element for the portal is either missing or incorrectly specified.

     class Portal extends Component {

        setup() {

            const node = this.__owl__;

            onMounted(() => {

                const portal = node.bdom;

                if (!portal.target) {

                    const target = document.querySelector(this.props.target);

                    if (target) {

                        portal.content.moveBeforeDOMNode(target.firstChild, target);

                    }

                    else {

                        throw new OwlError("invalid portal target");

                    }

                }

            });

            onWillUnmount(() => {

                const portal = node.bdom;

                portal.remove();

            });

        }

    }

    Portal.template = "__portal__";

    Portal.props = {

        target: {

            type: String,

        },

        slots: true,

    };

形象
丢弃
相关帖文 回复 查看 活动
0
7月 17
2942
2
8月 25
2705
1
7月 25
1083
1
8月 25
1151
0
5月 25
1507