


Below I will share with you an article about the v-for loading local static image method in vue. It has a good reference value and I hope it will be helpful to everyone.
The local images in the vue-cli project are placed in the assets directory (because the initial vue image of vue-cli is in it, so all the images are placed in it);
After that v-for encountered a problem when dynamically loading the image path
Source code:
<ul> <li v-for="(item,index) in teamInfo" @click="trastFun(item)"> <p><img src="/static/imghwm/default1.png" data-src="item.imageurl" class="lazy" v-bind:/ alt="Implement the method of loading local static images through v-for in vue (detailed tutorial)" ></p> <p>{{item.name}}</p> <p>{{item.position}}</p> <p class="icon-vs">VS</p> </li> </ul> for(var i = 0;i<self.teamInfo.length;i++){ var j= i+1; self.teamInfo[i].imageurl = '../../assets/crop'+j+'.png'; }
It turns out that although the src path of img is loaded in the browser, the image is not displayed. Baidu later found that the webpack package was parsed into a string, not the real path
Changed to
for(var i = 0;i<self.teamInfo.length;i++){ var j= i+1; self.teamInfo[i].imageurl = require('../../assets/crop'+j+'.png'); }
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Vue project turns off eslint verification
JS method to implement traversing irregular multi-dimensional arrays
#JS implementation example of adding event function to dynamically added elements
# #
The above is the detailed content of Implement the method of loading local static images through v-for in vue (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!
![在Illustrator中加载插件时出错[修复]](https://img.php.cn/upload/article/000/465/014/170831522770626.jpg)
启动AdobeIllustrator时是否会弹出加载插件时出错的消息?一些Illustrator用户在打开该应用程序时遇到了此错误。消息后面紧跟着一系列有问题的插件。该错误提示表明已安装的插件存在问题,但也可能是由于VisualC++DLL文件损坏或首选项文件受损等其他原因引起。如果遇到此错误,我们将在本文中指导您修复问题,请继续阅读以下内容。在Illustrator中加载插件时出错如果您在尝试启动AdobeIllustrator时收到“加载插件时出错”的错误消息,您可以使用以下用途:以管理员身

字幕在你的WindowsPC上不能在Stremio上运行吗?一些Stremio用户报告说,视频中没有显示字幕。许多用户报告说遇到了一条错误消息,上面写着“加载字幕时出错”。以下是与此错误一起显示的完整错误消息:加载字幕时出错加载字幕失败:这可能是您正在使用的插件或您的网络有问题。正如错误消息所说,可能是您的互联网连接导致了错误。因此,请检查您的网络连接,并确保您的互联网工作正常。除此之外,这个错误的背后可能还有其他原因,包括字幕加载项冲突、特定视频内容不支持字幕以及Stremio应用程序过时。如

Vue是一种现代化的JavaScript框架,它可以帮助我们轻松构建动态网页和复杂的应用程序。在Vue中,使用v-for可以轻松创建循环结构,对数据进行迭代渲染。而在一些特定的场景中,我们还可以利用v-for实现动态排序。本文将介绍如何在Vue中使用v-for实现动态排序的技巧,以及一些应用场景及示例。一、使用v-for进行简单

汽水音乐本地音乐怎么添加?汽水音乐APP中可以添加自己喜爱的本地音乐,但是多数的小伙伴不知道如何添加本地音乐,接下来就是小编为用户带来的汽水音乐本地音乐添加方法图文教程,感兴趣的用户快来一起看看吧!汽水音乐使用教程汽水音乐本地音乐怎么添加1、首先打开汽水音乐APP,主页面最下方【音乐】功能专区点击;2、之后进入到播放页面,点击右下角【三个点】图标;3、最后下方展开功能栏,选择其中【下载】按钮即可添加到本地音乐。

如果您在向Outlook插入超链接时遇到冻结问题,可能是由于网络连接不稳定、Outlook版本旧、防病毒软件干扰或加载项冲突等原因。这些因素可能导致Outlook无法正常处理超链接操作。修复插入超链接时Outlook冻结的问题使用以下修复程序解决插入超链接时Outlook冻结的问题:检查已安装的加载项更新Outlook暂时禁用您的防病毒软件,然后尝试创建新的用户配置文件修复办公室应用程序卸载并重新安装Office我们开始吧。1]检查已安装的加载项可能是Outlook中安装的某个加载项导致了问题。

随着互联网的发展,越来越多的网页需要支持滚动加载,而无限滚动加载是其中的一种。它可以让页面不断加载新的内容,使用户可以更流畅地浏览网页。在这篇文章中,我们将介绍如何使用PHP实现无限滚动加载。一、什么是无限滚动加载?无限滚动加载是一种基于滚动条的网页内容加载方式。它的原理是当用户滚动至页面底部时,通过AJAX异步调取后台数据,实现不断加载新的内容。这种加载方

PHP保存远程图片到本地后如何添加水印并保存?在PHP开发中,经常会遇到需要将远程图片保存到本地的需求。而有时候,我们可能还需要在保存后的图片上添加水印以保护版权或增加额外信息。本文将介绍如何使用PHP保存远程图片到本地,并在保存后的图片上添加水印。一、保存远程图片到本地首先,我们需要使用PHP的文件操作函数将远程图片保存到本地。下面是一个简单的示例代码:&

随着数码技术的不断进步,前端开发已经成为一个越来越受欢迎的职业。而Vue3由于其简单易用、高效稳定的特性,成为了越来越多开发者的首选。其中,v-for函数是Vue3中用于列表数据渲染的核心函数之一。在这篇文章中,我们将对Vue3中的v-for函数进行详解,让你能够更好地运用它解决实际开发中的问题。一、基础语法v-for函数的基础语法如下:<divv-


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version