Gradient 渐变颜色 #
注意:背景颜色必须设置透明 Gradient 才会生效
background-color: transparent;
数据结构 #
export interface QTGradient {
type?: QTGradientType
shape?: QTGradientShape
orientation?: QTGradientOrientation
colors: Array<string>
gradientRadius?: number
cornerRadius?: number
cornerRadii4?: Array<number>
cornerRadii8?: Array<number>
}
export enum QTGradientOrientation {
QT_GRADIENT_ORIENTATION_TOP_BOTTOM = 0,
QT_GRADIENT_ORIENTATION_TR_BL = 1,
QT_GRADIENT_ORIENTATION_RIGHT_LEFT = 2,
QT_GRADIENT_ORIENTATION_BR_TL = 3,
QT_GRADIENT_ORIENTATION_BOTTOM_TOP = 4,
QT_GRADIENT_ORIENTATION_BL_TR = 5,
QT_GRADIENT_ORIENTATION_LEFT_RIGHT = 6,
QT_GRADIENT_ORIENTATION_TL_BR = 7,
}
export enum QTGradientShape {
QT_GRADIENT_SHAPE_RECTANGLE = 0,
QT_GRADIENT_SHAPE_OVAL = 1,
QT_GRADIENT_SHAPE_LINE = 2,
QT_GRADIENT_SHAPE_RING = 3,
}
export enum QTGradientType {
QT_GRADIENT_TYPE_LINEAR_GRADIENT = 0,
QT_GRADIENT_TYPE_RADIAL_GRADIENT = 1,
QT_GRADIENT_TYPE_SWEEP_GRADIENT = 2,
}
基础用法 #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-start-css"
:gradientBackground="{
type: 0,
shape: 0,
colors: ['#ff0000', '#00ff00'],
cornerRadii4: [0, 5, 20, 0],
}"
/>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: '使用初探',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-start-css {
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
</style>
Type #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-type-css"
:gradientBackground="{
type: 0,
shape: 0,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="LINEAR"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-type-css"
:gradientBackground="{
type: 1,
shape: 0,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="RADIAL"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-type-css"
:gradientBackground="{
type: 2,
shape: 0,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="SWEEP"
/>
</qt-view>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'GradientType',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-type-css {
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
.qt-sdk-content-item-text-css {
width: 200px;
height: 200px;
text-align: center;
color: black;
}
</style>
Shape #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-shape-css"
:gradientBackground="{
type: 0,
shape: 0,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="RECTANGLE"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-shape-css"
:gradientBackground="{
type: 0,
shape: 1,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="OVAL"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-shape-css"
:gradientBackground="{
type: 0,
shape: 2,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="LINE"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-shape-css"
:gradientBackground="{
type: 0,
shape: 3,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="RING"
/>
</qt-view>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'GradientShape',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-shape-css {
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
.qt-sdk-content-item-text-css {
width: 200px;
height: 200px;
text-align: center;
color: black;
}
</style>
Orientation #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 0,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="TOP_BOTTOM"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 1,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="TR_BL"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 2,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="RIGHT_LEFT"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 3,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="BR_TL"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 4,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="BOTTOM_TOP"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 5,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="BL_TR"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 6,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="LEFT_RIGHT"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-orientation-css"
:gradientBackground="{
type: 0,
shape: 0,
orientation: 7,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="TL_BR"
/>
</qt-view>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'GradientType',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-orientation-css {
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
.qt-sdk-content-item-text-css {
width: 200px;
height: 200px;
text-align: center;
color: black;
}
</style>
CornerRadius #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-radius-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadius: 5,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadius:5"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-radius-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadius: 10,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadius:10"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-radius-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadius: 20,
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadius:20"
/>
</qt-view>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'CornerRadius',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-radius-css {
width: 250px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
.qt-sdk-content-item-text-css {
width: 250px;
height: 200px;
text-align: center;
color: black;
}
</style>
CornerRadii4 #

点击查看源码
<template>
<div class="es-sdk-root-css" :clipChildren="false">
<s-title-view class="es-sdk-content-title-css" :text="$options.name" />
<div class="es-sdk-content-divider-css" />
<qt-row class="qt-sdk-content-row-css">
<qt-view
class="qt-sdk-content-item-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadii4: [30, 30, 30, 30],
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadii4: [30,30,30,30]"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadii4: [10, 30, 20, 0],
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadii4: [10,30,20,0]"
/>
</qt-view>
<qt-view
class="qt-sdk-content-item-css"
:gradientBackground="{
type: 0,
shape: 0,
cornerRadii4: [10, 0, 30, 5],
colors: ['#ff0000', '#00ff00'],
}"
>
<qt-text
class="qt-sdk-content-item-text-css"
gravity="center"
text="CornerRadii4: [10,0,30,5]"
/>
</qt-view>
</qt-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'CornerRadii4',
})
</script>
<style>
.qt-sdk-content-row-css {
width: 1920px;
height: 1080px;
align-items: center;
justify-content: center;
}
.qt-sdk-content-item-css {
width: 400px;
height: 200px;
align-items: center;
justify-content: center;
margin: 20px;
background-color: transparent;
}
.qt-sdk-content-item-text-css {
width: 400px;
height: 200px;
text-align: center;
color: black;
}
</style>