编译到app会报错当在uni-app renderjs中使用bigint等新特性
编译到app会报错当在uni-app renderjs中使用bigint等新特性
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Windows | 11 23H2 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
PC开发环境操作系统版本号:11 23H2
HBuilderX类型:正式
HBuilderX版本号:4.66
手机系统:Android
手机系统版本号:Android 11
手机厂商:OPPO
手机机型:Reno5
页面类型:vue
vue版本:vue3
打包方式:云端
项目创建方式:HBuilderX
## 示例代码:
``` html
<template>
<view class="main-container">
<view id="myMapViews" style="height: 100%;width: 100%;" />
</view>
</template>
<script module="myMapViews" lang="renderjs">
const aa = 123n
// import Map from "@arcgis/core/Map"
// import MapView from "@arcgis/core/views/MapView"
// export default {
// name: 'myMapView',
// data() {
// return {};
// },
// mounted() {
// this.createMapView()
// },
// methods: {
// createMapView() {
// const map = new Map({
// basemap: 'dark-gray',
// })
// const mapView = new MapView({
// map,
// container: 'myMapViews',
// center: [102.92934063304513, 25.102234987110343],
// zoom: 3,
// })
// }
// }
// }
</script>
<style>
.main-container {
width: 100vw;
height: 100vh;
}
</style>
操作步骤:
Hbuilder X 4.66 创建新项目“uni-app”+“默认模板”+Vue3。(不选择uni app x)
在index.vue中复制代码(其实只需在renderjs中输入const aa = 123n,这是上一个帖子的示例)
<template>
<view class="main-container">
<view id="myMapViews" style="height: 100%;width: 100%;" />
</view>
</template>
<script module="myMapViews" lang="renderjs">
const aa = 123n
</script>
<style>
.main-container {
width: 100vw;
height: 100vh;
}
</style>
将其运行到APP基座
预期结果:
正常编译
实际结果:
<stdin>:2:12: ERROR: Big integer literals are not available in the configured target environment ("es2015")
bug描述:
在Hbuilder X 4.66中使用<script module="xxx" lang="renderjs">,
在renderjs中写const aa = 123n,然后运行到APP
日志:<stdin>:2:12: ERROR: Big integer literals are not available in the configured target environment (“es2015”)
操作场景:
本来是想使用arcgis for js实现地图展示,但是在APP端编译时就提示Big integer literals are not available in the configured target environment (“es2015”)等消息。
然后查找解决方案:https://ask.dcloud.net.cn/question/180135
这是2023年10月的帖子,指出“HBuilderX 3.97.2023110504-alpha 已修复。”
但是当前我在4.66版本无法执行
更多关于编译到app会报错当在uni-app renderjs中使用bigint等新特性的实战教程也可以访问 https://www.itying.com/category-93-b0.html
看原始帖子里,需要同步修改 build.target ,bigint 需要 chrome67
vite.config.js 里添加下面配置
build: {
target: [‘chrome67’]
},
更多关于编译到app会报错当在uni-app renderjs中使用bigint等新特性的实战教程也可以访问 https://www.itying.com/category-93-b0.html
你现在解决了吗 我也遇到一样的问题
这是因为uni-app在编译renderjs时,默认的ES版本配置不支持BigInt等ES2020新特性。renderjs模块在编译时被配置为ES2015目标环境,而BigInt字面量(如123n)是ES2020中引入的特性。
解决方案是在manifest.json中配置renderjs的编译目标版本:
{
"app-plus": {
"renderjs": {
"target": "es2020"
}
}
}

