定价方案列表
用法
PricingPlans 组件提供了一个灵活的布局,可以通过默认插槽或 plans
prop 来显示一系列 PricingPlan 组件。
<template>
<UPricingPlans>
<UPricingPlan
v-for="(plan, index) in plans"
:key="index"
v-bind="plan"
/>
</UPricingPlans>
</template>
plans
prop,也适用于默认插槽。计划
将 plans
prop 用作具有 PricingPlan 组件属性的对象数组。
- 一位开发者
- 终身访问
- 最多 5 位开发者
- Solo 版本的所有功能
- 最多 20 位开发者
- Startup 版本的所有功能
<script setup lang="ts">
const plans = ref([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<UPricingPlans :plans="plans" />
</template>
Orientation
使用 orientation
prop 来更改 PricingPlans 的方向。默认为 horizontal
。
- 一位开发者
- 终身访问
- 最多 5 位开发者
- Solo 版本的所有功能
- 最多 20 位开发者
- Startup 版本的所有功能
<script setup lang="ts">
const plans = ref([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<UPricingPlans orientation="vertical" :plans="plans" />
</template>
plans
prop 而不是默认插槽时,计划的 orientation
会自动反转,horizontal
变为 vertical
,反之亦然。紧凑
使用 compact
prop 来减小计划之间的填充,当其中一个计划被缩放时,以获得更好的视觉平衡。
- 一位开发者
- 终身访问
- 最多 5 位开发者
- Solo 版本的所有功能
- 最多 20 位开发者
- Startup 版本的所有功能
<script setup lang="ts">
const plans = ref([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<UPricingPlans compact :plans="plans" />
</template>
缩放
使用 scale
prop 来调整计划之间的间距,当其中一个计划被缩放时,以获得更好的视觉平衡。
- 一位开发者
- 终身访问
- 最多 5 位开发者
- Solo 版本的所有功能
- 最多 20 位开发者
- Startup 版本的所有功能
<script setup lang="ts">
const plans = ref([
{
title: 'Solo',
description: 'Tailored for indie hackers.',
price: '$249',
features: [
'One developer',
'Lifetime access'
],
button: {
label: 'Buy now'
}
},
{
title: 'Startup',
description: 'Best suited for small teams.',
price: '$499',
scale: true,
features: [
'Up to 5 developers',
'Everything in Solo'
],
button: {
label: 'Buy now'
}
},
{
title: 'Organization',
description: 'Ideal for larger teams and organizations.',
price: '$999',
features: [
'Up to 20 developers',
'Everything in Startup'
],
button: {
label: 'Buy now'
}
}
])
</script>
<template>
<UPricingPlans scale :plans="plans" />
</template>
示例
在页面内
在页面中使用 PricingPlans 组件来创建定价页面
<script setup lang="ts">
const { data: plans } = await useAsyncData('plans', () => queryCollection('plans').all())
</script>
<template>
<UPage>
<UPageHero title="Pricing" />
<UPageBody>
<UContainer>
<UPricingPlans :plans="plans" />
</UContainer>
</UPageBody>
</UPage>
</template>
plans
使用 `@nuxt/content` 模块中的 queryCollection
进行获取。API
属性
属性 | 默认值 | 类型 |
---|---|---|
as |
|
此组件应渲染为的元素或组件。 |
plans |
| |
orientation |
|
定价计划的方向。 |
紧凑 |
|
当为 |
scale |
|
当为 |
插槽
插槽 | 类型 |
---|---|
default |
|
主题
export default defineAppConfig({
ui: {
pricingPlans: {
base: 'flex flex-col gap-y-8',
variants: {
orientation: {
horizontal: 'lg:grid lg:grid-cols-[repeat(var(--count),minmax(0,1fr))]',
vertical: ''
},
compact: {
false: 'gap-x-8'
},
scale: {
true: ''
}
},
compoundVariants: [
{
compact: false,
scale: true,
class: 'lg:gap-x-13'
}
]
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pricingPlans: {
base: 'flex flex-col gap-y-8',
variants: {
orientation: {
horizontal: 'lg:grid lg:grid-cols-[repeat(var(--count),minmax(0,1fr))]',
vertical: ''
},
compact: {
false: 'gap-x-8'
},
scale: {
true: ''
}
},
compoundVariants: [
{
compact: false,
scale: true,
class: 'lg:gap-x-13'
}
]
}
}
})
]
})
更新日志
5cb65
— 特性:导入 @nuxt/ui-pro
组件