【发布时间】:2018-12-24 08:23:18
【问题描述】:
我有以下React Native 项目:
https://snack.expo.io/BkBU8fAlV
我有以下代码:
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
// You can import from local files
import AssetExample from './components/AssetExample';
// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';
import HomerSvg from './assets/HomerSvg';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.paragraph}>
Change code in the editor and watch it change on your phone! Save to get a shareable url.
</Text>
<View style={{ width: 80, height: 80 }}>
<HomerSvg />
</View>
<Card>
<AssetExample />
</Card>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
padding: 8,
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
});
我通过组件显示SVG 图像:HomerSvg,它使用了react-native-svg 包。
我需要以某种方式调整SVG 图像的大小。上面的代码我试了一下,没有成功。
我尝试给容器视图一些宽度和高度,但没有成功。
您知道我该如何实现吗?
谢谢!
【问题讨论】:
-
Resize 适用于您已经应用的宽度和高度,您能解释一下吗?
-
你能显示你解析的代码吗?
标签: javascript reactjs react-native svg expo