Home >Web Front-end >JS Tutorial >Loop through and load different images in vue2.0 (detailed tutorial)

Loop through and load different images in vue2.0 (detailed tutorial)

亚连
亚连Original
2018-06-01 10:35:143127browse

Below I will share with you a method of looping through and loading different images in vue2.0. It has a good reference value and I hope it will be helpful to everyone.

demo:

    <p v-for="item in temps" :key="item.id">
     <p class="contract-item">
       <img :src="item.imgUrl">
     </p>
    </p>

Introduce pictures, pay attention to the path:

import con1 from "@/assets/img/con01.png";
import con2 from "@/assets/img/con02.png";
import con3 from "@/assets/img/con03.png";

Load the image:

 temps: [
    {
     imgUrl: con1
    },
    {
     imgUrl: con2
    },
    {
     imgUrl: con3
    },
   ],

This enables loading different images during loop traversal.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

In the bottom navigation bar in vue.js, how to display the first-level route and the solution to the problem that the sub-route is not displayed?

How to implement random WeChat signal switching code through JavaScript (detailed tutorial)

Reload the current routing page according to AngularJS , what are the methods?

The above is the detailed content of Loop through and load different images in vue2.0 (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn