thx / gogocode

GoGoCode is a transformer for JavaScript/Typescript/HTML based on AST but providing a more intuitive API.
MIT License
5.63k stars 426 forks source link

事件API转换失败 #253

Open laiyanzhang opened 3 months ago

laiyanzhang commented 3 months ago

版本:0.2.28 描述:执行事件API转化时出现部分事件API没有成功转化的情况 步骤: 1、执行转化命令gogocode -s ./src/views/components/businessFlow/components/Edit.vue -t gogocode-plugin-vue -o ./src/views/components/businessFlow/components/Edit1.vue 2、报错

文件转换异常,规则:eventsApi,文件:F:\xuanwu\IdeCopy\src\views\components\businessFlow\components\Edit.vue Error: replace failed: $emit(Bus, `removeTab-${this.curTabParams.name}`
this.curTabParams.name) cannot be parsed!
    at Array.forEach (<anonymous>)
    at Object.replaceSelBySel (F:\nvm\v14.20.0\node_modules\gogocode-cli\node_modules\gogocode\src\js-core\core.js:196:22)
    at AST.replace (F:\nvm\v14.20.0\node_modules\gogocode-cli\node_modules\gogocode\src\Ast.js:421:19)
    at Object.module.exports [as rule] (F:\nvm\v14.20.0\node_modules\gogocode-plugin-vue\src\events-api.js:77:14)
    at F:\nvm\v14.20.0\node_modules\gogocode-plugin-vue\index.js:42:28
    at Array.reduce (<anonymous>)
    at transform (F:\nvm\v14.20.0\node_modules\gogocode-plugin-vue\index.js:37:37)
    at F:\nvm\v14.20.0\node_modules\gogocode-cli\src\commands\transform.js:194:22
    at Array.forEach (<anonymous>)

3、文件报错定位代码:Bus.$emit(`removeTab-${this.curTabParams.name}`, this.curTabParams.name) 预期:事件API的转化能全部转化成功 其他:除此之外大部分链式调用皆无法转化成功,比如Bus.$off(`removeTab-${curTabParams.name}`).$on()