如何在背景图片上设置Vue Css变量

问题描述 投票:0回答:1

` 这是我的状态 const icon = ref('image.jpg')

 <style scoped>
 background-image: url(icon);
 </style>

 This approach is not working please advise how to go about it

 background-image: url(icon);

 This approach is not working please advise how to go about it`
vuejs3
1个回答
0
投票

尝试像在模板中那样调用它

<style scoped>
background-image: url({{ icon }});
</style>
© www.soinside.com 2019 - 2024. All rights reserved.