Skip to content

Instantly share code, notes, and snippets.

@mudream4869
Last active July 25, 2018 11:37
Show Gist options
  • Select an option

  • Save mudream4869/d956736a96bac2a89155a0c416a0ac35 to your computer and use it in GitHub Desktop.

Select an option

Save mudream4869/d956736a96bac2a89155a0c416a0ac35 to your computer and use it in GitHub Desktop.
vue-jscolor
Vue.component('jscolor', {
template: '<input v-model="value" class="jscolor"/>',
props : ['value'],
mounted : function(){
window.jscolor.installByClassName('jscolor');
this.$el.jscolor.fromString(this.value);
$(this.$el).on('change', function(_this){
return function(){
_this.$emit('input', this.value);
}
}(this));
},
watch : {
"value" : function(val){
this.$el.jscolor.fromString(val);
}
}
});
@mudream4869
Copy link
Copy Markdown
Author

Build a jscolor vue component

@niveshsaharan
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment