Last active
July 25, 2018 11:37
-
-
Save mudream4869/d956736a96bac2a89155a0c416a0ac35 to your computer and use it in GitHub Desktop.
vue-jscolor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build a jscolor vue component