我想将图像 url 传递给子组件,但图像未显示。
我试过v-attr, :attr,:src属性。
页面/index.vue
<ThumbNail img-url="assets/img/igsim_intro.png"/>
Run Code Online (Sandbox Code Playgroud)
组件/缩略图.vue
<!-- Failed to resolve directive: attr -->
<img v-attr="imgUrl" />
<!-- 404 Not found: http://localhost:3000/assets/img/pds_main.png -->
<img :src="imgUrl" />
<img :attr="{src: imgUrl}" />
Run Code Online (Sandbox Code Playgroud)
<script>
export default {
name: "ThumbNail",
props: {
imgUrl: {
type: String,
default: ''
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我希望Thumbnail.vue将图像显示为传递的 url。