uni-app 5.14 Compiles Vue <teleport> Directly to Mini Program <root-portal>
Cross-platform Vue projects that target both H5 and Chinese mini programs can drop a whole class of conditional compilation. The unified syntax reduces template duplication and the bugs that come from maintaining parallel overlay strategies.
Writing a modal, drawer, or toast in a cross-platform Vue app used to require separate code paths: <teleport> for H5 and <root-portal> for mini programs. uni-app 5.14 removes that split. Developers write standard Vue <teleport to="body"> and the compiler transforms it into the platform's native <root-portal> at build time.
The transformation is a capability mapping, not a full polyfill. Mini program <root-portal> only elevates content to the page root; it cannot target arbitrary nodes the way Web Teleport can. Attributes that have no mini program equivalent, like `to` and `defer`, are silently dropped during compilation. The `disabled` prop is automatically negated to match <root-portal>'s inverted `enable` attribute.
Support currently covers WeChat, Alipay, and JD mini programs. H5 builds continue to use Vue's real <teleport> unchanged, so a single template now works across all targets without conditional compilation blocks.
Capability mapping rather than full simulation is a pragmatic choice: it avoids the performance and complexity cost of trying to replicate DOM-like behavior inside a mini program runtime that fundamentally lacks it.
The automatic negation of `disabled` to `enable` is a small but sharp detail — it prevents the common bug where a developer forgets to invert the boolean when switching between platforms.