【问题标题】:can't use svg files with react-native不能将 svg 文件与 react-native 一起使用
【发布时间】:2021-06-24 02:41:58
【问题描述】:

我需要显示 svg 文件并找到 react-native-remote-svg 包。但我找不到它,不知道如何解决它任何人都可以帮助解决这个问题?

there is the warning

import {View, Text} from 'react-native';
import Image from 'react-native-remote-svg';

const App = () => {
  return (
    <View>
      <Image
        source={{
          uri:
            'https://example.com/my-https://s3.us-east-2.amazonaws.com/nomics-api/static/images/currencies/btc.svgpic.svg',
        }}
        style={{width: 200, height: 532}}
      />
    </View>
  );
};

export default App; ```



【问题讨论】:

    标签: react-native svg


    【解决方案1】:

    使用这个 react 原生库

    https://github.com/vault-development/react-native-svg-uri

    这取决于 react-native-svg 库,所以你需要两者

    【讨论】:

      【解决方案2】:

      要渲染远程 SVG 图像,更好的方法是使用 https://github.com/react-native-svg/react-native-svg

      对于您的情况:

      import * as React from 'react';
      import { SvgUri } from 'react-native-svg';
      
       export default () => (
        <SvgUri
         width="200"
         height="532"
         uri="https://example.com/my-https://s3.us-east-2.amazonaws.com/nomics-api/static/images/currencies/btc.svgpic.svg"
        />
       );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-21
        • 2016-08-03
        • 1970-01-01
        • 1970-01-01
        • 2017-08-19
        • 2018-06-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多