当前位置:   article > 正文

用 AI 生成 Vue 组件?_vue0

vue0

大家好我是奇兵,三个月前,Vercel 推出了其 AI 代码生成工具 —— v0(v0.dev),这款工具可以快速生成前端组件代码,引起了前端圈的广泛关注。通过简单的描述,v0能够快速生成前端页面,让AI在前端开发领域的潜力更进一步展现出来,距离 AI 替代前端开发更近一步?在此之后,陆续出现了多个 v0 的替代品,下面就来分享两个好玩又好用的 AI 代码生成工具!

vue0

vue0 是最近刚开源的一个 AI 工具,借助 Open AI 实现。通过简单的描述,就可以快速生成一个 Vue 页面,目前支持 shadcn/vue,但很快就会支持更多的 UI 库。

图片

vue0 的特性如下:

  • 编写多遍步骤

  • 编写迭代步骤

  • 将组件存储在 fs 中

  • 渲染生成的代码

  • 添加用户功能

  • 屏幕截图生成组件

  • 简单元数据

  • 改进缓存

下面是使用 vue0 快速生成 Vue 页面的教程:

,时长00:47

比如,对于以下页面:

图片

生成的代码如下:

 
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import { Check } from 'lucide-vue-next';
  4. import { Switch } from '@/components/ui/switch';
  5. import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
  6. import { Button } from '@/components/ui/button';
  7. const isYearly = ref(false);
  8. </script>
  9. <template>
  10. <div class="p-10 bg-gray-100 dark:bg-black">
  11. <div class="max-w-7xl mx-auto">
  12. <div class="text-center mb-8">
  13. <h2 class="text-3xl font-bold text-gray-800 dark:text-white">Pricing Plans</h2>
  14. <p class="text-md text-gray-600 dark:text-gray-300">Choose the plan that's right for you.</p>
  15. </div>
  16. <div class="mb-8 text-center">
  17. <label for="pricing-toggle" class="inline-flex items-center cursor-pointer">
  18. <span class="mr-2 text-gray-600 dark:text-gray-400">Monthly</span>
  19. <Switch
  20. id="pricing-toggle"
  21. v-model="isYearly"
  22. aria-label="Toggle between month/year pricing"
  23. class="mx-auto"
  24. />
  25. <span class="ml-2 text-gray-600 dark:text-gray-400">Yearly</span>
  26. </label>
  27. </div>
  28. <div class="grid md:grid-cols-3 gap-8">
  29. <!-- Cards will go here with isYearly logic for pricing -->
  30. <Card class="shadow-lg">
  31. <CardHeader>
  32. <CardTitle class="text-xl font-semibold text-gray-800 dark:text-white">Basic</CardTitle>
  33. <CardDescription class="text-gray-500 dark:text-gray-400">For individual use</CardDescription>
  34. </CardHeader>
  35. <CardContent>
  36. <p class="text-4xl font-bold text-gray-800 dark:text-white">$0<span class="text-sm">{{ isYearly ? '/yr' : '/mo' }}</span></p>
  37. <ul class="mt-4">
  38. <li class="flex items-center text-gray-600 dark:text-gray-300">
  39. <Check class="mr-2 w-4 h-4 text-green-500" /> 1 Project
  40. </li>
  41. <li class="flex items-center text-gray-600 dark:text-gray-300">
  42. <Check class="mr-2 w-4 h-4 text-green-500" /> 100MB Storage
  43. </li>
  44. </ul>
  45. </CardContent>
  46. <CardFooter>
  47. <Button variant="outline">Get Started</Button>
  48. </CardFooter>
  49. </Card>
  50. <!-- Repeat for other cards -->
  51. <Card class="shadow-lg">
  52. <CardHeader>
  53. <CardTitle class="text-xl font-semibold text-gray-800 dark:text-white">Pro</CardTitle>
  54. <CardDescription class="text-gray-500 dark:text-gray-400">For professionals</CardDescription>
  55. </CardHeader>
  56. <CardContent>
  57. <p class="text-4xl font-bold text-gray-800 dark:text-white">$10<span class="text-sm">{{ isYearly ? '/yr' : '/mo' }}</span></p>
  58. <ul class="mt-4">
  59. <li class="flex items-center text-gray-600 dark:text-gray-300">
  60. <Check class="mr-2 w-4 h-4 text-green-500" /> 10 Projects
  61. </li>
  62. <li class="flex items-center text-gray-600 dark:text-gray-300">
  63. <Check class="mr-2 w-4 h-4 text-green-500" /> 5GB Storage
  64. </li>
  65. </ul>
  66. </CardContent>
  67. <CardFooter>
  68. <Button variant="secondary">Get Started</Button>
  69. </CardFooter>
  70. </Card>
  71. <!-- Repeat for other cards -->
  72. <Card class="shadow-lg">
  73. <CardHeader>
  74. <CardTitle class="text-xl font-semibold text-gray-800 dark:text-white">Enterprise</CardTitle>
  75. <CardDescription class="text-gray-500 dark:text-gray-400">For organizations</CardDescription>
  76. </CardHeader>
  77. <CardContent>
  78. <p class="text-4xl font-bold text-gray-800 dark:text-white">$99<span class="text-sm">{{ isYearly ? '/yr' : '/mo' }}</span></p>
  79. <ul class="mt-4">
  80. <li class="flex items-center text-gray-600 dark:text-gray-300">
  81. <Check class="mr-2 w-4 h-4 text-green-500" /> Unlimited Projects
  82. </li>
  83. <li class="flex items-center text-gray-600 dark:text-gray-300">
  84. <Check class="mr-2 w-4 h-4 text-green-500" /> 100GB Storage
  85. </li>
  86. </ul>
  87. </CardContent>
  88. <CardFooter>
  89. <Button variant="destructive">Get Started</Button>
  90. </CardFooter>
  91. </Card>
  92. </div>
  93. </div>
  94. </div>
  95. </template>

Github:https://github.com/zernonia/vue0

openv0

openv0 是一个生成式UI组件框架,凭借AI技术,可以轻松实现UI组件的实时预览、生成与迭代。它深度整合丰富的开源组件库与图标,为生成式工作流提供一站式资源。其设计核心理念在于高度模块化与精细的生成过程管理,确保流程的灵活与高效。组件生成采用多步骤管道化流程,每一步都由独立插件执行,进一步提升了整个流程的灵活性和效率。

图片

openv0 目前支持的前端框架有:

  • React

  • Next.js

  • Svelte

支持的 UI 库有:

  • NextUI

  • Flowbite

  • Shadcn

下面是使用 openv0 快速生成页面的教程:

,时长01:10

Github:https://github.com/raidendotai/openv0/

大家不妨试一下。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/822569
推荐阅读
相关标签
  

闽ICP备14008679号