mirror of
				https://github.com/vuejs/babel-plugin-jsx.git
				synced 2025-11-04 03:12:20 +08:00 
			
		
		
		
	support v-show
This commit is contained in:
		@@ -111,6 +111,11 @@ const transformJSXAttribute = (path, attributesToMerge, directives, injected) =>
 | 
				
			|||||||
      : name.replace(`v${name[1]}`, name[1].toLowerCase());
 | 
					      : name.replace(`v${name[1]}`, name[1].toLowerCase());
 | 
				
			||||||
    if (directiveName === '_model') {
 | 
					    if (directiveName === '_model') {
 | 
				
			||||||
      directives.push(getJSXAttributeValue(path));
 | 
					      directives.push(getJSXAttributeValue(path));
 | 
				
			||||||
 | 
					    } else if (directiveName === 'show') {
 | 
				
			||||||
 | 
					      directives.push(t.arrayExpression([
 | 
				
			||||||
 | 
					        injected.vShow,
 | 
				
			||||||
 | 
					        getJSXAttributeValue(path),
 | 
				
			||||||
 | 
					      ]));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      directives.push(t.arrayExpression([
 | 
					      directives.push(t.arrayExpression([
 | 
				
			||||||
        t.callExpression(injected.resolveDirective, [
 | 
					        t.callExpression(injected.resolveDirective, [
 | 
				
			||||||
@@ -323,12 +328,16 @@ module.exports = () => ({
 | 
				
			|||||||
        if (!state.vueResolveDirectiveInjected) {
 | 
					        if (!state.vueResolveDirectiveInjected) {
 | 
				
			||||||
          state.vueResolveDirectiveInjected = addNamed(path, 'resolveDirective', 'vue');
 | 
					          state.vueResolveDirectiveInjected = addNamed(path, 'resolveDirective', 'vue');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (!state.vueVShowInjected) {
 | 
				
			||||||
 | 
					          state.vueVShowInjected = addNamed(path, 'vShow', 'vue');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        path.replaceWith(
 | 
					        path.replaceWith(
 | 
				
			||||||
          transformJSXElement(path, {
 | 
					          transformJSXElement(path, {
 | 
				
			||||||
            h: state.vueCreateElementInjected,
 | 
					            h: state.vueCreateElementInjected,
 | 
				
			||||||
            mergeProps: state.vueMergePropsInjected,
 | 
					            mergeProps: state.vueMergePropsInjected,
 | 
				
			||||||
            withDirectives: state.vueWithDirectivesInjected,
 | 
					            withDirectives: state.vueWithDirectivesInjected,
 | 
				
			||||||
            resolveDirective: state.vueResolveDirectiveInjected,
 | 
					            resolveDirective: state.vueResolveDirectiveInjected,
 | 
				
			||||||
 | 
					            vShow: state.vueVShowInjected,
 | 
				
			||||||
          }),
 | 
					          }),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user