[dcloudio/uni-app]微信小程序使用async语法出现错误

2023-12-08 176 views
2

问题描述 [问题描述:尽可能简洁清晰地把问题描述清楚] 使用async函数会出现报错

[这里请贴上你的报错截图或文字] image

补充信息 [可选] [根据你的分析,出现这个问题的原因可能在哪里?] 如果关闭小程序的es6转es5 会出现其他报错,这些其他报错在开启es6转es5时不会出现 image

回答

8

关闭小程序的es6转es5,并贴出其他错误

4

已经查出错误所在,由于vant-weapp这个ui库是es6代码,放在static目录无法被编译,我该如何解决这个问题呢

3

我以前在mpvue使用async并且勾选了es6转es5 没有出错,这。。。我该咋办

9

@zhetengbiji 如果我坚持使用vant-weapp的ui库 那就必须开启小程序的es6转es5 ,请问除了async不能用,还有什么问题吗

3

static目录的文件不走编译,可以转换好再放进去

4

怎么编译呢?vant发布的dist就是这样的

1

问题根本没有合理的解决,即使存放在wxcomponents目录,依然不会编译成es5,uniapp-ui的组件目前没做到过渡效果,同样的popup组件,我肯定选择vant的,uniapp的生态欠佳

2

你的组件不要放在static目录下呀发自我的华为手机-------- 原始邮件 --------主题:Re: [dcloudio/uni-app] 微信小程序使用async语法出现错误 (#256)发件人:Chaves Gu 收件人:dcloudio/uni-app 抄送:Subscribed @brucehelen 可以看一下我的临时解决方案

https://juejin.im/post/5c9b25e06fb9a070bf3605ed

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/dcloudio/uni-app","title":"dcloudio/uni-app","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/dcloudio/uni-app"}},"updates":{"snippets":[{"icon":"PERSON","message":"@chavesgu in #256: @brucehelen 可以看一下我的临时解决方案\r\nhttps://juejin.im/post/5c9b25e06fb9a070bf3605ed"}],"action":{"name":"View Issue","url":"https://github.com/dcloudio/uni-app/issues/256#issuecomment-477019880"}}}

[

{

"@context": "http://schema.org",

"@type": "EmailMessage",

"potentialAction": {

"@type": "ViewAction",

"target": "https://github.com/dcloudio/uni-app/issues/256#issuecomment-477019880",

"url": "https://github.com/dcloudio/uni-app/issues/256#issuecomment-477019880",

"name": "View Issue"

},

"description": "View this Issue on GitHub",

"publisher": {

"@type": "Organization",

"name": "GitHub",

"url": "https://github.com"

}

}

]

0

async await 报错的问题修复 在cli工程目录执行 npm install regenerator-runtime@0.12.1 --save 然后运行测试

8

你也太会玩了 加了这个库,vue的语法都报错了,编译出现问题了,2个v-for嵌套,里面的v-for拿不到外层v-for的变量了

7

@zhetengbiji @xiaoyucoding 你们这线上的东西就这么随便加了regenerator-runtime这个库? 有bug都加?

0

1.regenerator-runtime本身就有 2.之所以出现 async 的错误,是因为regenerator-runtime版本升级导致在小程序环境出问题(动态 Function) 3.锁定到0.12.1版本可以解决上述 async 问题 4.语法报错是因为新版本 cli 默认启用了新编译器,同时提供了降级配置 manifest.json->mp-weixin

9

小程序的组件库,不能用在H5上。为了多端统一,还是放弃使用vant-weapp小程序组件库。

0

HBuilderX 1.8.0 已修复此问题,cli 已同步更新。

6

cli版本2.0.0-29820201110001将微信小程序转为支付宝小程序的时候,遇到了Function(...) is not a function,后来查明async/await问题,查看到你的答案后 regenerator-runtime: "^0.13.7" 降级为 "^0.12.1"后,支付宝小程序终于可以正常运行了,感谢