<div v-for="item in imgList">
	<img  @click="getava($event)" ref="myava" class="mess-ava mess-ava-change" v-bind:src="item.url" />
	
</div>
imgList:[
	{
		name: "1",
		url: require(`../../public/img/1.jpg`)
	},
	{
		name: "2",
		url: require(`../../public/img/2.jpg`)
	},
	{
		name: "3",
		url: require(`../../public/img/3.jpg`)
	},
	{
		name: "4",
		url: require(`../../public/img/4.jpg`)
	},

	
],
//获取对象
getava(event){
	var target = event.target || window.event.srcElement
	       //获取对应元素的id值
	var text = target.getAttribute('src');
	console.log("src----------------"+text);
}
Logo

前往低代码交流专区

更多推荐