rgb滑块_前端开发的技术博客_51CTO博客
source link: https://blog.51cto.com/u_15473285/5849000
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
rgb滑块
精选 原创晨曦前端 2022-11-14 13:23:25 博主文章分类:vue ©著作权
文章标签 javascript 文章分类 JavaScript 前端开发 阅读数247
<template>
<div>
<div class="bac" :style="`background:rgb${rgb}`">
RGB颜色: rgb({{red}},{{green}},{{blue}})
</div>
<div class="box">
<div class="block">
<span class="demonstration">RED</span>
<el-slider
v-model="red"
:max=255
@input="redChange">
</el-slider>
</div>
<div class="block">
<span class="demonstration">GREEN</span>
<el-slider
v-model="green"
:max=255
@input="greenChange">
</el-slider>
</div>
<div class="block">
<span class="demonstration">BLUE</span>
<el-slider
v-model="blue"
:max=255
@input="blueChange">
</el-slider>
</div>
</div>
</div>
</template>
<script>
export default {
data(){
return {
red: 49,
green: 120,
blue: 200,
rgb: `(0,0,0)`
}
},
methods:{
redChange(newValue){
this.rgb = `(${newValue},${this.green},${this.blue})`
},
greenChange(newValue){
this.rgb = `(${this.red},${newValue},${this.blue})`
},
blueChange(newValue){
this.rgb = `(${this.red},${this.green},${newValue})`
}
},
mounted(){
}
};
</script>
<style lang="scss" scoped>
.bac {
height: 200px;
background: rgb(0, 0, 0);
margin-bottom: 50px;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-weight: 700;
font-size: 20px;
}
.box {
width: 700px;
display: flex;
justify-content: space-between;
align-items: center;
}
.block {
width: 150px;
.demonstration {
font-weight: 700;
}
}
</style>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK