codercup / unibest

unibest - 最好用的 uniapp 开发框架。unibest 是由 uniapp + Vue3 + Ts + Vite4 + UnoCss + UniUI 驱动的跨端快速启动模板,使用 VS Code 开发,具有代码提示、自动格式化、统一配置、代码片段等功能,同时内置了大量平时开发常用的基本组件,开箱即用,让你编写 uniapp 拥有 best 体验。
https://codercup.github.io/unibest-docs/
MIT License
1.4k stars 178 forks source link

Unbalanced delimiter found in string #19

Closed dhanweb closed 4 months ago

dhanweb commented 4 months ago
// #ifdef VUE3
// #ifdef APP-PLUS
global = {}
// #endif
// #endif
// #ifndef APP-NVUE
import {Canvas, setCanvasCreator, dispatch} from './canvas';
import {wrapTouch, convertTouchesToArray, devicePixelRatio ,sleep, canIUseCanvas2d, getRect} from './utils';
// #endif
// #ifdef APP-NVUE
import { base64ToPath, sleep } from './utils';
import {Echarts} from './nvue'
// #endif
const charts = {}
const echartsObj = {}

uniapp条件编译表达式和格式化冲突了,编译就会报错Unbalanced delimiter found in string 这其中一部分是我在插件市场下载的echarts组件的多端兼容的代码,新建个vue文件,粘贴这段代码,保存格式化之后条件编译语句就会发现错乱了。 目前我是一个一个手动改正的,有什么好的解决方案吗。

codercup commented 4 months ago

看起来是有2层条件编译,我不知道这是否合理。

不过你说的格式化问题确实是一个问题,我后空研究下。

codercup commented 4 months ago
// #ifdef VUE3
// #ifdef APP-PLUS
global = {}
// #endif
// #endif
// #ifndef APP-NVUE
import {Canvas, setCanvasCreator, dispatch} from './canvas';
import {wrapTouch, convertTouchesToArray, devicePixelRatio ,sleep, canIUseCanvas2d, getRect} from './utils';
// #endif
// #ifdef APP-NVUE
import { base64ToPath, sleep } from './utils';
import {Echarts} from './nvue'
// #endif
const charts = {}
const echartsObj = {}

uniapp条件编译表达式和格式化冲突了,编译就会报错Unbalanced delimiter found in string 这其中一部分是我在插件市场下载的echarts组件的多端兼容的代码,新建个vue文件,粘贴这段代码,保存格式化之后条件编译语句就会发现错乱了。 目前我是一个一个手动改正的,有什么好的解决方案吗。

方便提供原始代码块吗?我们本地复现一下,方便修复

dhanweb commented 4 months ago

l-echart.zip 这个是插件市场下载的echarts组件的其中一个文件,包括script标签内和style标签内的的格式化问题,我都是在这个文件发现的。 还有个比较复杂的,条件编译下可能会写多个return,这样后面的return都会爆红线,例如这个文件的 canvasToTempFilePath 方法。

codercup commented 4 months ago

目前已经有一个 ucharts 的 unibest 模板,或许能帮到你。

dhanweb commented 4 months ago

目前已经有一个 ucharts 的 unibest 模板,获取能帮到你。

好的,非常感谢