Symptom
When linearGradient is set, the background color gradient instead of the text gradient is used by default. How to implement the text gradient?
Possible Causes
The linearGradient attribute is used for the component content and is drawn on the background. Therefore, if the attribute is set only for text, the effect is displayed on the background color instead of the text. The effect is as follows:

Solution
To implement the text gradient effect, use the following methods:
1. Versions earlier than API20
The sample code of implementing the text gradient effect is as follows:
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Row() {
Text(this.message)
.fontSize(24)
.fontWeight(FontWeight.Bold)
.blendMode(BlendMode.DST_IN, BlendApplyType.OFFSCREEN)
}
.linearGradient({
direction: GradientDirection.Right,
colors: [['#ff0631f5', 0.0], ['#ff922626', 1]]
})
.blendMode(BlendMode.SRC_OVER, BlendApplyType.OFFSCREEN)
}
.width('100%')
.height('100%')
}
} 
2. Versions later than API20
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Text(this.message)
.fontSize(24)
.fontWeight(FontWeight.Bold)
.shaderStyle({
direction: GradientDirection.Right,
colors: [['#ff0631f5', 0.0], ['#ff922626', 1]]
})
}
.width('100%')
.height('100%')
}
} For more text effects, see Text Effects Based on the Text Component and Common Properties.