diff --git a/packages/babel-plugin-jsx/README-zh_CN.md b/packages/babel-plugin-jsx/README-zh_CN.md index cb8c2314..0cbeaa5d 100644 --- a/packages/babel-plugin-jsx/README-zh_CN.md +++ b/packages/babel-plugin-jsx/README-zh_CN.md @@ -162,10 +162,14 @@ const App = { ```jsx +// 或者 + ``` ```jsx +// 或者 + ``` 会编译成: diff --git a/packages/babel-plugin-jsx/README.md b/packages/babel-plugin-jsx/README.md index 7e7ddb69..a67ea457 100644 --- a/packages/babel-plugin-jsx/README.md +++ b/packages/babel-plugin-jsx/README.md @@ -166,10 +166,14 @@ const App = { ```jsx +// Or + ``` ```jsx +// Or + ``` Will compile to: diff --git a/packages/babel-plugin-jsx/src/parseDirectives.ts b/packages/babel-plugin-jsx/src/parseDirectives.ts index d6e5b9de..3395ab99 100644 --- a/packages/babel-plugin-jsx/src/parseDirectives.ts +++ b/packages/babel-plugin-jsx/src/parseDirectives.ts @@ -67,7 +67,7 @@ const parseDirectives = (params: { .replace(/^\S/, (s: string) => s.toLowerCase()); if (directiveArgument) { - args.push(t.stringLiteral(directiveArgument)); + args.push(t.stringLiteral(directiveArgument.split('_')[0])); } const isVModels = directiveName === 'models'; diff --git a/packages/babel-plugin-jsx/test/v-model.test.tsx b/packages/babel-plugin-jsx/test/v-model.test.tsx index 2b7b9022..32880111 100644 --- a/packages/babel-plugin-jsx/test/v-model.test.tsx +++ b/packages/babel-plugin-jsx/test/v-model.test.tsx @@ -286,3 +286,48 @@ test('Named model', async () => { await wrapper.trigger('click'); expect(wrapper.html()).toBe('