PricingPlansPRO
用法
PricingPlans 组件提供灵活的布局,用于使用默认插槽或 plans
属性显示 PricingPlan 组件列表。
<template>
<UPricingPlans>
<UPricingPlan
v-for="(plan, index) in plans"
:key="index"
v-bind="plan"
/>
</UPricingPlans>
</template>
plans
属性,也适用于默认插槽。计划
使用 plans
属性作为对象数组,其中包含 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
属性更改 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
属性而不是默认插槽时,计划的方向会自动反转,horizontal
变为 vertical
,反之亦然。紧凑
当其中一个计划被缩放以获得更好的视觉平衡时,使用 compact
属性来减少计划之间的间距。
- 一位开发者
- 终身访问
- 最多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
属性来调整计划之间的间距。
- 一位开发者
- 终身访问
- 最多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
使用 queryCollection
从 @nuxt/content
模块获取。API
属性
属性 | 默认值 | 类型 |
---|---|---|
as |
|
此组件应渲染为的元素或组件。 |
plans |
| |
orientation |
|
定价计划的方向。 |
紧凑 |
|
当为 |
scale |
|
当为 |
插槽
插槽 | 类型 |
---|---|
默认 |
|
主题
export default defineAppConfig({
uiPro: {
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({
uiPro: {
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 uiPro from '@nuxt/ui-pro/vite'
export default defineConfig({
plugins: [
vue(),
uiPro({
uiPro: {
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'
}
]
}
}
})
]
})