最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue中本地靜態(tài)圖片的路徑應該怎么寫

 更新時間:2023年10月17日 08:51:52   作者:開心大表哥  
這篇文章主要介紹了vue中本地靜態(tài)圖片的路徑應該怎么寫,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

vue中本地靜態(tài)圖片的路徑應該怎么寫

需求

如何components里面的index.vue怎樣能把assets里面的圖片拿出來。

1.在img標簽里面直接寫上路徑:

<img src="../assets/a1.png" class="" width="100%"/>

2.利用數(shù)組保存再循環(huán)輸出:

<el-carousel-item v-for="item in carouselData" :key="item.id">
      	<img :src="item.url" class="carouselImg"/>
        <span class="carouselSpan">{{ item.title }}</span>
</el-carousel-item>
data: () => ({
      carouselData:[
      {url:require('../assets/a1.png'),title:'你看我叼嗎1',id:1},
      {url:require('../assets/a3.png'),title:'你看我叼嗎2',id:2},
      {url:require('../assets/a4.png'),title:'你看我叼嗎3',id:3}
      ]
    }),

效果如下:

index.vue里面的完整代碼是這個:

<template>
  <div>
    <div class=" block">
    <el-carousel class="carouselBlock">
      <el-carousel-item v-for="item in carouselData" :key="item.id">
      	<img :src="item.url" class="carouselImg"/>
        <span class="carouselSpan">{{ item.title }}</span>
      </el-carousel-item>
    </el-carousel>
  	</div>
  
  <footer1></footer1>
  <img src="../assets/a1.png" class="" width="100%"/>
  </div>
</template>
<script>
	import footer1 from '../components/public/footer'
    export default {
    data: () => ({
      carouselData:[
      {url:require('../assets/a1.png'),title:'你看我叼嗎1',id:1},
      {url:require('../assets/a3.png'),title:'你看我叼嗎2',id:2},
      {url:require('../assets/a4.png'),title:'你看我叼嗎3',id:3}
      ]
    }),
    components:{
    		footer1
    	},
  }
</script>

<style lang="scss">
	@import '../style/mixin';
	.carouselBlock{
		width: 100%;
		height: REM(300);
		position:relative;
		.carouselImg{
  		height: REM(300);
  		width:100%;
	  }
	  .carouselSpan{
	  	position: absolute;
	  	bottom: REM(20);
	  	left: REM(20);
	  	font-size: REM(24);
	  	font-weight: bold;
	  }
	}
	.el-carousel__container{
		width: 100%;
		height: REM(300);
	}
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
     background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
     background-color: #d3dce6;
  }
  
</style>

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

莎车县| 石阡县| 确山县| 阳谷县| 漾濞| 平阴县| 怀来县| 灵寿县| 涿鹿县| 岳普湖县| 盐边县| 余干县| 离岛区| 吴川市| 辽阳县| 屯留县| 北碚区| 麻江县| 襄汾县| 洪江市| 鄂托克旗| 若羌县| 青州市| 额尔古纳市| 盱眙县| 上虞市| 门源| 桃源县| 阜新| 富宁县| 屯留县| 永春县| 镇宁| 富阳市| 临湘市| 楚雄市| 来凤县| 高平市| 黑龙江省| 延庆县| 吕梁市|