問題分析:
使用vue添加背景圖片時,剛開始是加在css樣式上,然后路徑也沒錯,但是瀏覽器上會把圖片路徑轉成base64,但是圖片大小超過閾值就不轉了,直接引入背景圖片用在瀏覽器上時,由於路徑解析的問題,圖片並不能夠正確的顯示出來
解決方案:
<template>
<div class="head" :style="note">
<span>收銀台</span>
</div>
</template>
<script>
export default{
data(){
return{
note:{
backgroundImage:"url("+require('../../../../../../static/img/shop/homeg/arrowsg.png')+")",
backgroundSize:".18rem .32rem",
backgroundRepeat:"no-repeat",
backgroundPosition:".4rem .28rem"
}
}
}
}
</script>