在Vue Native中添加静态图像资源

时间:2019-01-19 15:14:35

标签: react-native vue.js vue-native

我了解到,为了在本机反应中添加静态图像资源,必须静态知道图像。这是通过以下方式完成的:

Multihop attempted

在vue native中,例如在react native中,使用

var icon = this.props.active
  ? require('./my-icon-active.png')
  : require('./my-icon-inactive.png');
<Image source={icon} />;

将不起作用,因为静态图像不是静态已知的。 如何在Vue Native中使图像静态已知?

1 个答案:

答案 0 :(得分:1)

在Vue-Native中,您需要这样编写:

<image
:source="require('./my-icon.png')"
/>

{}放在""之间