You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在不使用符号链接的情况下在移动端与Web端共享组件?

跨端项目结构方案对比

这里有两种适配Web和移动端的项目结构方案,具体情况如下:

首选方案

该方案的目录结构如下:

components/
platforms/
  web/
    index.tsx
  mobile/
    index.tsx

它在移动端可以正常运行,但在Web端会抛出Uncaught ReferenceError: React is not defined的错误。

可行方案

该方案的目录结构如下(* 代表符号链接):

web/
  index.tsx
  shared/ *
    components
mobile/
  index.tsx
  shared/ *
    components/

这个方案在移动端和Web端都能正常运行,但需要依赖符号链接来实现。

内容的提问来源于stack exchange,提问作者Leau

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 18:45:48