Skip to content

Instantly share code, notes, and snippets.

@e1blue
Last active June 20, 2018 12:30
Show Gist options
  • Select an option

  • Save e1blue/8a4d5106b46d6e6aecdc820ca736c39a to your computer and use it in GitHub Desktop.

Select an option

Save e1blue/8a4d5106b46d6e6aecdc820ca736c39a to your computer and use it in GitHub Desktop.
Vue Identicon
<div id="app"></div>
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>
`
});
<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