dcloudio / dcloudio/uni-app

微信小程序导入代码出错(vite构建)

Open
#3,602 5 comments 0 reactions 1 assignee Claimed by @fxy060608 View on GitHub
bug vue3
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
微信小程序导入代码出错,其它平台表现正常。

**复现步骤**
新建 `src/utils/index.ts`,然后写入方法:
```ts
export function doSomething() {
// 执行过程
}
```
然后在页面中导入方法
```vue

// import { doSomething } from '@/utils';
import { doSomething } from '../../utils';

```

**预期结果**
正常导入并运行。

**实际结果**
无法正常运行代码,并报了以下错误
![image](https://user-images.githubusercontent.com/24738011/173557759-2a20ed89-d28b-47ad-a24f-82fe7966652b.png)
![image](https://user-images.githubusercontent.com/24738011/173554344-8061361e-7a12-4e51-b1d2-7e117aab6544.png)
![image](https://user-images.githubusercontent.com/24738011/173554431-fbad369e-4d5c-4d6e-9efb-9dc5a1ab4840.png)

**系统信息:**
- 发行平台: 微信小程序
- 操作系统 [如 iOS 12.1.2、Android 7.0]
- HBuilderX版本: 3.4.7.20220422
- uni-app版本: 如下图
- 设备信息 [如 iPhone8 Plus]

![image](https://user-images.githubusercontent.com/24738011/173557081-bf1a0465-dd10-4737-bb72-e0621506ff66.png)

**补充信息**
[可选]
[根据你的分析,出现这个问题的原因可能在哪里?]

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.