Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1501 Ansichten

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)

Avatar
Verwerfen
Beste Antwort

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,

    };

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Juli 17
2942
2
Aug. 25
2704
1
Juli 25
1083
1
Aug. 25
1151
0
Mai 25
1507