Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法正常使用重新导出的组件吗? #5211

Open
yxw007 opened this issue Nov 1, 2024 · 0 comments
Open

无法正常使用重新导出的组件吗? #5211

yxw007 opened this issue Nov 1, 2024 · 0 comments

Comments

@yxw007
Copy link

yxw007 commented Nov 1, 2024

背景

随着项目的增大,components 目录下的组件也来越多,找组件也变得不好看了。那么我就想着能否把组件归类至对应目录,避免一级目录太多了。

环境

  • OS: win10
  • 运行平台:微信小程序
  • uniapp: 3.0.0-alpha-4030120241009001

例子

  • 导出

    //  src/pages/page-test/page-test.vue
    <template>
      <view>
      	商品详情xxxxx
      </view>
    </template>
    
    <script setup>
    </script>
    //  src/pages/page-product-detail/template/index.js
    
    import template0 from "./template0.vue";
    import template1 from "./template1.vue";
    
    export {
        template0,
        template1
    }
  • 导入

    <template>
        <template0></template0>
    </template>
    
    <script setup>
    import { template0 } from "../page-product-detail/template";
    console.log("template0", template0);
    
    </script>

实际结果

无法渲染出template0组件
image

期望

能用这种重新导出和引入,让组件能正常渲染出来

@yxw007 yxw007 changed the title 【求助】组件无法重新导出吗? 无法正常使用重新导出的组件吗? Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant