版博士V2.0程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

37 行
1014 B

  1. const $ = require('../index');
  2. const code = `
  3. import { Button, jsx } from "@alifd/next";
  4. const Button1 = () => {
  5. return (
  6. <div>
  7. <h2>转译前</h2>
  8. <div>
  9. <Button type="normal">Normal</Button>
  10. <Button type="primary">Prirmary</Button>
  11. <Button type="secondary">Secondary</Button>
  12. <Button type="normal" text>Normal</Button>
  13. <Button type="primary" text>Primary</Button>
  14. <Button type="secondary" text>Secondary</Button>
  15. <Button type="normal" warning text="as" sss>Normal</Button>
  16. </div>
  17. </div>
  18. );
  19. };
  20. export default Button1;
  21. `
  22. const res = $(code)
  23. .replace(`import { $$$ } from "@alifd/next";`, `import { $$$ } from "antd";`)
  24. .replace(`<Button type="normal" $$$></Button>`, `<Button type="default" $$$></Button>`)
  25. .replace(`<Button text $$$></Button>`, `<Button $$$ type="link"></Button>`)
  26. .replace(`<Button warning $$$></Button>`, `<Button danger $$$></Button>`)
  27. .generate()
  28. console.log(res)