div背景图片_Vue 各种坑总结(swiper、背景图片)

2a52c444fdbcf67b8120e2b1cd64388d.png

swiper 的使用
全局引入

  • CDN 模式,在 index.html 直接使用。
   <link rel="stylesheet" href="https://unpkg.com/swiper/css/swiper.min.css">
   <script src="https://unpkg.com/swiper/js/swiper.min.js"> </script>
      //引入
   <div class="swiper-container">
       <div class="swiper-wrapper">
       	<img src="/static/images/topic_1_b.png" class="swiper-slide"/>
       	<img src="/static/images/topic_1_b.png" class="swiper-slide"/>
       	<img src="/static/images/topic_1_b.png" class="swiper-slide"/>
       </div>
   </div>
   
   //初始化,必须在 挂载阶段。
   mounted() {
   	new Swiper('.swiper-container', {
   	      slidesPerView: 'auto',
   	      spaceBetween: 30,
   	      pagination: {
   	        el: '.swiper-pagination',
   	        clickable: true,
   	      },
   	});
   }

vue-awesome-swiper的使用 (暂未有时间,有空编写)

背景图片为动态时

    <template>
        <div class="header" :style=" `background: url(${ bck_url }) center no-repeat;`">
            
        </div>
    </template>

当背景图片为动态且 图片路径为 src 下, 引入时 , vue 会不解析 图片地址。而 还是 字符串

正常情况下,例如 header.png 图片 会解析为 header_3.4e7ddc9.png ,

解决方法:

- 图片放在静态资源下, `static` 下
原文链接:Vue 各种坑总结(swiper、背景图片)
作者:北风丶
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值