How to insert image in ionic 2

后端 未结 9 1876
星月不相逢
星月不相逢 2020-12-28 08:10

I\'m new on ionic 2 and i\'m trying to insert an image, but i don\'t realize the real path. inside the file app/pages/getting-started/getting-started.html

&         


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 08:49

    Tested with Ionic2.rc2:

    The default build takes the images under src/assets/img and puts it under assets/img. In order to reference them from the scss files you need to go up a folder:

    background: url('../assets/img/sports-backgrounds.jpg');
    

    That's the only way I got it to work, even even leaving out the '../' worked on the browser while testing.

    At the same time, if you're referencing the images from the view (html files), here's what works for me:

    Ionic 2 is somewhat unstable so there're still some quirks that need to be ironed out.

    Good luck.

提交回复
热议问题