When we learn HTML, the image tag <img> introduces images <img src="../assets/images/avatar.png" width="100%"> But this has two disadvantages:
what to do? Use dynamic path import and requireFirst, let's talk about these two brothers. Before ES6, JS did not have its own module syntax. In order to solve this embarrassment, require.js was created. After ES6 was released, JS introduced the concept of import. Import using import After importing, you need to register it in data, otherwise it will not be displayed <script> import lf1 from '@/assets/images/cityOfVitality/lf1.png' import lf2 from '@/assets/images/cityOfVitality/lf2.png' import lf3 from '@/assets/images/cityOfVitality/lf3.png' import lf4 from '@/assets/images/cityOfVitality/lf4.png' import lf5 from '@/assets/images/cityOfVitality/lf5.png' import lf6 from '@/assets/images/cityOfVitality/lf6.png' import lf7 from '@/assets/images/cityOfVitality/lf7.png' import top1 from '@/assets/images/cityOfVitality/icon_top1.png' import mixins from './mixins' export default { name: 'LeftPiece', mixins: [mixins], data () { return { lf1, lf2, lf3, lf4, lf5, lf6, lf7, top1 } } } </script> Import using require<script> import top1 from '@/assets/images/cityOfVitality/icon_top1.png' import mixins from './mixins' export default { name: 'RightPiecr', mixins: [mixins], data () { return { rt1: require('@/assets/images/cityOfVitality/rt1.png'), rt2: require('@/assets/images/cityOfVitality/rt2.png'), rt3: require('@/assets/images/cityOfVitality/rt3.png'), rt4: require('@/assets/images/cityOfVitality/rt4.png'), rt5: require('@/assets/images/cityOfVitality/rt5.png'), rt6: require('@/assets/images/cityOfVitality/rt6.png'), top1 } } } </script> This is the end of this article about how to introduce img images into Vue pages. For more relevant content about how to introduce img images into Vue, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: MySQL transaction autocommit automatic commit operation
Preface This article lists several common, practi...
1. First create the file (cd to the directory whe...
Table of contents Preface Demand Analysis Mysql u...
Table of contents MySQL Client/Server Protocol If...
Table of contents 1. Anti-shake function 2. Use d...
A simple license plate input component (vue) for ...
After setting up the MySQL master-slave, you ofte...
One of our web projects has seen an increase in t...
Table of contents Preface No.1 A focus No.2 Extra...
Table of contents Local Mixin Global Mixins Summa...
Table of contents 1. What is a doubly linked list...
1. Why do we need to divide tables and partitions...
First, let's talk about why we use provide/in...
Table of contents JavaScript events: Commonly use...
I recently wanted to convert a website to https a...