vue-template-babel-compiler icon indicating copy to clipboard operation
vue-template-babel-compiler copied to clipboard

[Fixed Bug] template里面写对象方法的简写形式报错

Open jayzun opened this issue 3 years ago • 2 comments

<div :rules="[{ transform(value) { return +value} }]"></div>

改成这样就不报错

<div :rules="[{ transform: function(value) { return +value} }]"></div>

报错信息:

[vite-plugin-vue2] /Users/admin/work/code/brick/esop2-support/VueTemplateBabelCompiler: Property key of ObjectMethod expected node to be of a type ["Identifier","StringLiteral","NumericLiteral"] but instead got "MemberExpression"

jayzun avatar Jul 14 '22 02:07 jayzun

这是个BUG。感谢你的反馈😊

shouldPrependVm()[objectMethod](https://babeljs.io/docs/en/babel-types#objectmethod)类型的AST节点,错误地返回了 true,给transform()错误地加上了_vm.前置。

我们增加一个 t.isObjectMethod(path.container) 应该能修复问题。

7589f0f50d989df466e46b10c77d089

欢迎你发个 PullRequest 修复这个问题!

你可以参考 CONTRIBUTING.md 调试、增加测试用例、创建 PR.

JuniorTour avatar Jul 17 '22 14:07 JuniorTour

This issue has been fixed by v2.0, try it by: npm install vue-template-babel-compiler@latest

JuniorTour avatar Feb 23 '23 12:02 JuniorTour