About the problem of dynamic splicing src image address of img in Vue

About the problem of dynamic splicing src image address of img in Vue

Let's take a look at the dynamic splicing of img in Vue: src picture address, the specific content is as follows:

Usage scenario: Match local image resources according to the image tag returned by the backend. For example: According to the k1 tag returned by the backend, the front end generates the image resource path assets/images/inventory/k1.png

<template>
    <div class="fl">
          <img :src="getImgUrl(gatherInfo.img1)" alt="">
          <img :src="getImgUrl(gatherInfo.img2)" alt="">
          <img :src="getImgUrl(gatherInfo.img3)" alt="">
     </div>
</template>
data(){
    return {
      gatherInfo:
        title: 'Inventory summary information',
        img1: 'k1',
        img2: 'k2',
        img3: 'k3',
      },
    }
}

In methods

//Get the image address getImgUrl (img) {
      return require("@/assets/images/inventory/" + img+ ".png");
    },

This is the end of this article about dynamic splicing of img in Vue: src image address. For more relevant vue img dynamic splicing content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue render function dynamically loads img's src path operation
  • Use vue to dynamically splice urls through variables
  • Some experience on dynamic splicing of vue src path

<<:  How to configure MySQL8 in Nacos

>>:  How to install tomcat in docker and deploy the Springboot project war package

Recommend

Vue project realizes login and registration effect

This article example shares the specific code of ...

Detailed description of component-based front-end development process

Background <br />Students who work on the fr...

My CSS framework - base.css (reset browser default style)

Copy code The code is as follows: @charset "...

Comparison of mydumper and mysqldump in mysql

If you only want to back up a few tables or a sin...

Introduction to encryption of grub boot program in Linux

Table of contents 1. What is grub encryption 2. g...

Window.name solves the problem of cross-domain data transmission

<br />Original text: http://research.microso...

Complete steps to quickly configure HugePages under Linux system

Preface Regarding HugePages and Oracle database o...

Working principle and example analysis of Linux NFS mechanism

What is NFS? network file system A method or mech...

Why should css be placed in the head tag

Think about it: Why should css be placed in the h...

Implementation of CSS linear gradient concave rectangle transition effect

This article discusses the difficulties and ideas...

CSS selects the first child element under the parent element (:first-child)

Preface I recently used :first-child in a project...

VMware configuration hadoop to achieve pseudo-distributed graphic tutorial

1. Experimental Environment serial number project...

Summary of 10 advanced tips for Vue Router

Preface Vue Router is the official routing manage...

Native JavaScript message board

This article shares the specific code of JavaScri...