这篇文章主要介绍“html中阴影样式怎么设置”,在日常操作中,相信很多人在html中阴影样式怎么设置问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”html中阴影样式怎么
顺晟科技
2022-09-16 07:17:47
562
如题,vue如果动态设置input的颜色,网上查找的方法
this.$refs.xxxx.style.setProperty('color', 'red')
不起效果
刚才经过测试找到了解决的方案:
// demo.vue
<input
type="text"
placeholder="输入内容"
:style="bindInputStyle"
/>
...
computed:{
bindInputStyle() {
return {
'--placeholderColor': 'red',
}
},
}
...
<style scoped lang="scss">
input {
&::placeholder {
color: var(--placeholderColor); // 动态值
}
}
</style>
参考链接:
css的var的兼容
先试下:this.$refs.xxxx
是不是选中了当前 input dom元素。答案是是的话,再试试 this.$refs.xxxx.style.color = 'red'
。然后检查下 Element 面板,查看当前 input dom的样式是否生效。
19
2022-10
19
2022-10
19
2022-10
25
2022-09
16
2022-09
16
2022-09