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
Table of contents 1. Traversal Class 1. forEach 2...
Table of contents Linux--File descriptor, file po...
Pure js implements a single-click editable table ...
TabIndex is to press the Tab key to sequentially o...
Common nmcli commands based on RHEL8/CentOS8 # Vi...
Table of contents 1. Installation: 2. Use: 3. Bui...
Simply put, delayed replication is to set a fixed...
Table of contents 1. Decoupled assignment of arra...
MySql always pops up a MySQLInstallerConsole.exe ...
Data Sheet: Column to row: using max(case when th...
Sometimes it is necessary to perform simple verif...
This article shares the specific code of JavaScri...
This article shares the specific code for canvas ...
1. Download, install and configure mysql-8.0.15 1...
Preface You may often receive warning emails from...