diff --git a/packages/babel-plugin-jsx/README-zh_CN.md b/packages/babel-plugin-jsx/README-zh_CN.md index cb8c231..0cbeaa5 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 7e7ddb6..a67ea45 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 d6e5b9d..3395ab9 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 2b7b902..3288011 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('