Android 如何在my App.js视图中导入和使用SVG文件

Android 如何在my App.js视图中导入和使用SVG文件,android,reactjs,react-native,Android,Reactjs,React Native,我想在我的react原生项目的Appjs视图中导入它。 我尝试了很多方法,但都不管用。我的意思是我想在我的视图中渲染它。如何在Appjs中导入和显示此文件 这是我的密码: import ForwardRef from '../../constants/UI_login/Home_Landing_Page/BackgroundComponent' import React from "react"; import Svg, { Defs, LinearGradient, Stop, Rect }

我想在我的react原生项目的Appjs视图中导入它。 我尝试了很多方法,但都不管用。我的意思是我想在我的视图中渲染它。如何在Appjs中导入和显示此文件

这是我的密码:

import ForwardRef from '../../constants/UI_login/Home_Landing_Page/BackgroundComponent'
import React from "react";
import Svg, { Defs, LinearGradient, Stop, Rect } from "react-native-svg";
/* Adobe XD React Exporter has dropped some elements not supported by react-native-svg: style */

const BackgroundComponent = ({ svgRef }) => (
  <Svg width={375} height={247} viewBox="0 0 375 247" ref={svgRef}>
    <Defs>
      <LinearGradient
        id="a"
        x1={0.5}
        y1={0.807}
        x2={0.5}
        y2={1}
        gradientUnits="objectBoundingBox"
      >
        <Stop offset={0} stopColor="#fff" />
        <Stop offset={1} stopColor="#fff" stopOpacity={0} />
      </LinearGradient>
    </Defs>
    <Rect className="a" width={375} height={247} />
  </Svg>
);

const ForwardRef = React.forwardRef((props, ref) => (
  <BackgroundComponent svgRef={ref} {...props} />
));
export default ForwardRef;
从“../../constants/UI\u login/Home\u Landing\u Page/BackgroundComponent”导入ForwardRef
从“React”导入React;
从“react native Svg”导入Svg,{Defs,LinearGradient,Stop,Rect};
/*Adobe XD React Exporter已删除React原生svg:style不支持的某些元素*/
const BackgroundComponent=({svgRef})=>(
);
const ForwardRef=React.ForwardRef((道具,ref)=>(
));
导出默认ForwardRef;
App.js

import React from 'react';
import { StyleSheet} from 'react-native';
//import {Actions} from 'react-native-router-flux';
import Routes from './components/Routes';
import {firebaseConfig} from "./constants/ApiKeys";


import {AppContainer} from './components/Navigation'

import * as firebase from 'firebase';

if (!firebase.apps.length) { firebase.initializeApp(firebaseConfig); }

console.ignoredYellowBox = ['Setting a timer'];
export default class App extends React.Component {

  render() {
    return (

      <AppContainer/>

    );
  }
}
从“React”导入React;
从“react native”导入{StyleSheet};
//从“react native router flux”导入{Actions};
从“./组件/路由”导入路由;
从“/constants/apikees”导入{firebaseConfig}”;
从“./components/Navigation”导入{AppContainer}
从“firebase”导入*作为firebase;
如果(!firebase.apps.length){firebase.initializeApp(firebaseConfig);}
console.ignoredYellowBox=[“设置计时器”];
导出默认类App扩展React.Component{
render(){
返回(
);
}
}

该项目是如何构建的?你在使用网页包吗?这个项目是如何建立的可能的副本?你正在使用网页包吗?可能是重复的