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

Detailed explanation of MySQL slow queries

Query mysql operation information show status -- ...

Detailed explanation of the usage of MySQL memory tables and temporary tables

Usage of MySQL memory tables and temporary tables...

Detailed steps to install Sogou input method on Ubuntu 20.04

1. Install Fcitx input framework Related dependen...

CSS pseudo-element::marker detailed explanation

This article will introduce an interesting pseudo...

Key issues and solutions for web page access speed

<br /> The website access speed can directly...

What to do if you forget your Linux/Mac MySQL password

What to do if you forget your Linux/Mac MySQL pas...

Detailed explanation of the problem when combining CSS ellipsis and padding

Text truncation with CSS Consider the following c...

Nginx implements dynamic and static separation example explanation

In order to speed up the parsing of the website, ...

JavaScript custom calendar effect

This article shares the specific code of JavaScri...

Summary of Mysql high performance optimization skills

Database Command Specification All database objec...

Solution to MySQL root password error number 1045

Stop MySQL Service Windows can right-click My Com...

MySQL replication mechanism principle explanation

Background Replication is a complete copy of data...

How to use MySQL binlog to restore accidentally deleted databases

Table of contents 1 View the current database con...

How to solve the high concurrency problem in MySQL database

Preface We all know that startups initially use m...