A Pen by Pratik Naik on CodePen.
Last active
June 20, 2018 12:30
-
-
Save e1blue/8a4d5106b46d6e6aecdc820ca736c39a to your computer and use it in GitHub Desktop.
Vue Identicon
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
| <div id="app"></div> |
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
| new Vue({ | |
| el: '#app', | |
| data: { // Initialize our list of 'ingredients' | |
| textInput: '' | |
| }, | |
| computed: { // Turn data into viewable values | |
| identicon: function() { | |
| return jdenticon.toSvg(this.textInput, 200); // 200 is height & width | |
| }, | |
| reverse: function() { | |
| return this.textInput.split('').reverse().join(''); | |
| } | |
| }, | |
| methods: { // Use these functions to change data | |
| onInput: function(event) { | |
| // console.log('Someone typed something'); | |
| // console.log(event.target.value) | |
| this.textInput = event.target.value; // no need to refer as 'this.data.textInput' | |
| } | |
| }, | |
| template: ` | |
| <div> | |
| <h3>My Identicon Generator</h3> | |
| <div> | |
| Input: | |
| <input v-on:input="onInput"/> | |
| </div> | |
| <div> | |
| Output: | |
| {{ textInput.split('').reverse().join('') }} | |
| {{ reverse }} | |
| <div v-html="identicon"></div> | |
| <!-- {{identicon}} --> | |
| </div> | |
| </div> | |
| ` | |
| }); |
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
| <script src="https://cdn.rawgit.com/dmester/jdenticon/5bbdf8cb/dist/jdenticon.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment