css - 如何在本机反应中将线性渐变从 css 转换为线性渐变?
问题描述
我在 css 中有一个线性渐变,我想在 react native 中linear-gradient(315.43deg, #706EB6 -6.67%, #A57FCF 106.6%)
使用该组件。和propsLinearGradient
的等价物是什么start
,我如何从 css 中的线性渐变传递到原生反应?end
locations
解决方案
在 React Native 中,您可以像这样使用颜色属性
<LinearGradient colors={['transparent', '#000000']}>
</LinearGradient>
同理,你可以传递开始、结束位置
你可以在这里看到 LinearGradient 的道具
declare module 'react-native-linear-gradient' {
import * as React from 'react';
import * as ReactNative from 'react-native';
export interface LinearGradientProps extends ReactNative.ViewProps {
colors: (string | number)[];
start?: { x: number; y: number };
end?: { x: number; y: number };
locations?: number[];
useAngle?: boolean;
angleCenter?: {x: number, y: number};
angle?: number;
}
export class LinearGradient extends React.Component<LinearGradientProps> {}
export default LinearGradient;
}
推荐阅读
- angular - 错误类型错误:this.validator 不是函数 FormArray
- anaconda - 在 Linux 上从源代码构建 PyTorch 时出错
- java - 为什么常量池(在 Java 类文件中)从 1(而不是 0)开始索引?保留的 constant_pool[0] 条目是做什么用的?
- php - 如何显示来自不同表的类别名称而不是类别 ID
- python - 对数千个坐标进行反向地理编码以仅获取国家/地区
- java - 单击时正确生成整数
- php - PHP:编辑 JSON 字符串,传递变量值
- jquery - 如果类不可见,则 HTML 显示元素
- javascript - Lodash函数修改字符串数组中的每个元素
- python - 用漂亮的汤从 html 代码中提取表