[Vue.js] Use v-for command to traverse the picture

vue.js traverses the image array through the v-for instruction, first give an array, put the path of the picture in the array, use the v-for instruction to traverse the array, and bind the src attribute through the v-bind instruction. The attribute name.

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>v-for指令遍历图片</title>
	</head>
	<body>
		<div id="app">
			<!--s表示遍历出来的值,src表示遍历的数组-->
			<div v-for="s in src">
				<img :src="s.s1"/>
				<img :src="s.s2"/>
				<img :src="s.s3"/>
			</div>
		</div>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var vm=new Vue({
				el:"#app",
				data:{
					src:[
						{s1:"../img/1.jpeg"},
						{s2:"../img/2.jpg"},
						{s3:"../img/2.jpg"}
					]
				}
			});
		</script>
	</body>
</html>
Published 19 original articles · praised 20 · visits 491

Guess you like

Origin blog.csdn.net/Handsome_gir/article/details/105360836