dcloudio / dcloudio/uni-app

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

Open
#5,211 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

# 背景

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

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

# 例子

- 导出
```js
// src/pages/page-test/page-test.vue


商品详情xxxxx



```
```js
// src/pages/page-product-detail/template/index.js

import template0 from "./template0.vue";
import template1 from "./template1.vue";

export {
template0,
template1
}
```

- 导入

```js





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


```

## 实际结果
无法渲染出template0组件
![image](https://github.com/user-attachments/assets/f474becc-62ae-4019-83ca-d9e47e0d618d)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.