Vue3如何在SCSS中使用v-bind
作者:huanglihui1007
这篇文章主要介绍了Vue3如何在SCSS中使用v-bind,通过template先创建一个通用的页面结构,本文结合实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
template
先创建一个通用的页面结构
<template> <div class="v-bubble-bg"></div> </template>
js
在JS中先对需要用的数据进行定义:
可以是参数,也可以是data
<script setup>
const props = defineProps({
bgColor: {
type: String,
default: '#000000'
},
bgWidth: {
type: [Number, String],
default: '100%'
},
bgHeight: {
type: [Number, String],
default: '100%'
},
color: {
type: String,
default: 'rgba(255,255,255,.6)'
}
})
const pdata = reactive({
size: '12px'
})
</script>css
<style lang="scss" scoped>
.v-bubble-bg {
background-color: v-bind(bgColor);
width: v-bind(bgWidth);
height: v-bind(bgHeight);
overflow: hidden;
position: absolute;
left: 0;
top: 0;
font-size:v-bind('pdata.size')
}
</style>运行结果

到此这篇关于Vue3 在SCSS中使用v-bind的文章就介绍到这了,更多相关Vue3使用v-bind内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
