mounted: function()

in app/scripts/components.js [11:28]


  mounted: function () {
    var vm = this;
    var $el = $(this.$el);
    $el.find('input').val(this.color);
    $el.colorpicker().on('changeColor', function () {
      // Avoid colorpicker will format the color string and cause vm updated
      // twice when editing the hex value
      var colorStr = $el.find('input').val();
      var isColorValid = echarts.color.parse(colorStr);
      if (isColorValid) {
        vm.$set(vm, 'color', colorStr);
      }
    });
    vm.$watch('color', function(newV) {
      $el.colorpicker('setValue', newV);
      vm.$emit('update:color', newV);
    });
  },