当前位置:问答中心开发实战vue 如何动态设置input的placeholder的颜色?

vue 如何动态设置input的placeholder的颜色?

0
读者投稿 管理员 提问于 2年 前
// demo.vue
<input
      type="text"
      placeholder="输入内容"
      :style="bindInputStyle"
    />
...
computed:{
   bindInputStyle() {
        return {
          '--placeholderColor': 'red',
        }
      },
}
...

<style scoped lang="scss">
input {
  &::placeholder {
      color: var(--placeholderColor); // 动态值
    }
}
</style>