Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1515 Lượt xem

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)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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,

    };

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 17
2948
2
thg 8 25
2721
1
thg 7 25
1089
1
thg 8 25
1151
0
thg 5 25
1515