Ionic image loading tips
P粉416996828
P粉416996828 2023-08-26 20:03:50
0
1
576
<p>I'm just playing around with Ionic and Vue 3. </p> <p>But when I use the <code>ion-img</code> tag, the images loaded from the assets folder are not displayed correctly. </p> <p>Folder structure: </p> <pre class="brush:php;toolbar:false;">- assets -- logo.svg - views -- Authentication.vue</pre> <p>When I load the image using standard HTML <code>img</code> it works fine, but not when using <code>ion-img</code>. </p> <pre class="brush:php;toolbar:false;"><ion-row> <img src="../assets/logo.svg"/> <ion-img src="../assets/logo.svg"></ion-img> </ion-row></pre> <p>I have tried the following different src paths: </p> <pre class="brush:php;toolbar:false;">./assets/logo.svg ../assets/logo.svg ../../assets/logo.svg (unreasonable, but I tried it too) ~/assets/logo.svg</pre> <p>Any suggestions on this? </p>
P粉416996828
P粉416996828

reply all(1)
P粉281089485

Check out this answer:

How to reference static resources in vue javascript

In short, you can get the results you want by:

<ion-img :src="require('../assets/logo.svg')" />
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!