zoukankan      html  css  js  c++  java
  • vue-color 颜色选择器插件用法介绍

    // 首先安装依赖
    npm i vue-color
    
    <div>
        <div>color-picker</div>
        <p>Chrome</p>
        <chrome-picker v-model="colors" />
        <p>Sketch</p>
        <sketch-picker v-model="colors" />
        <p>Photoshop</p>
        <photoshop-picker v-model="colors" />
        <p>Material</p>
        <material-picker v-model="colors" />
        <p>Slider</p>
        <slider-picker v-model="colors" />
        <p>Compact</p>
        <compact-picker v-model="colors" />
        <p>Swatches</p>
        <swatches-picker v-model="colors" />
        <p>Twitter</p>
        <twitter-picker v-model="colors" />
        <p>Grayscale</p>
        <grayscale-picker v-model="colors" @input="updateValue" />
    </div>
    
    <script>
    import {
      Material,
      Compact,
      Swatches,
      Slider,
      Photoshop,
      Chrome,
      Sketch,
      Twitter,
      Grayscale,
    } from "vue-color";
    
    export default {
      name: "color-picker",
      components: {
        "material-picker": Material,
        "compact-picker": Compact,
        "swatches-picker": Swatches,
        "slider-picker": Slider,
        "photoshop-picker": Photoshop,
        "chrome-picker": Chrome,
        "sketch-picker": Sketch,
        "twitter-picker": Twitter,
        "grayscale-picker": Grayscale,
      },
      data() {
        return {
          colors: {
            color: "",
            hex: "#194d33",
            hsl: { h: 150, s: 0.5, l: 0.2, a: 1 },
            hsv: { h: 150, s: 0.66, v: 0.3, a: 1 },
            rgba: { r: 25, g: 77, b: 51, a: 1 },
            a: 1,
          },
        }
      },
      methods: {
        // 值改变事件
        updateValue(value) {
          console.log(value)
          console.log(this.color)
        }
      }
    }
    </script>
    
    你必须穷尽一生磨练技能,这就是成功的秘诀,也是让人家敬重的关键。
  • 相关阅读:
    C++函数声明与定义
    《寻找发帖“水王”》代码的理解
    将正整数转换为二进制数
    使用Cookie记住登录用户
    Java组合算法
    已知链表头结点指针head,写一个函数把这个链表逆序
    String.IsNullOrEmpty官方示例
    log4net的使用
    asp.net MVC4总结
    点击获取页面上的经纬度
  • 原文地址:https://www.cnblogs.com/knuzy/p/14339615.html
Copyright © 2011-2022 走看看