Home > Web Front-end > Vue.js > How to introduce img in vue.js

How to introduce img in vue.js

coldplay.xixi
Release: 2020-11-17 15:28:17
Original
2309 people have browsed it

How to introduce img in vue.js: 1. The image is returned to the network image path through the backend; 2. The image is introduced through require, the code is [imgUrl: {src: require('../assets/images) /index/banner.png')}].

How to introduce img in vue.js

【Related article recommendations: vue.js

vue.js introduces img Method:

Solution

The image can be returned to the network image path through the backend.

            <div class="banner-item"
              :style="{&#39;background&#39;: `url(${$base.urlImage}${item.shufflingUrl})`,&#39;background-size&#39;:&#39;cover&#39;}"
                 ></div>
Copy after login

Solution 2

Introducing pictures through require

  <script>
      export default {
          data() {
              return {
                  imgUrl: {
                      src: require(&#39;../assets/images/index/banner.png&#39;),
                  }
              }
          }
      }
  </script>
Copy after login
  <script>
      require oBanner from &#39;../assets/images/index/banner.png&#39;
      export default {
          data() {
              return {
                  imgUrl: {
                      src: oBanner,
                  }
              }
          }
      }
  </script>
Copy after login

The above introduces the problem of non-display of two kinds of pictures. I hope everyone has to help.

Related free learning recommendations: javascript (video)

The above is the detailed content of How to introduce img in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template