Created
August 9, 2016 11:17
-
-
Save sonus/d3a847c293558ca8f87314ab5f926dd3 to your computer and use it in GitHub Desktop.
vue.js
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Document</title> | |
| </head> | |
| <div id="app"> | |
| <h1 v-text="title"></h1> | |
| <input type="" v-model="title" name=""> | |
| <ul> | |
| <li v-for="todo in todos" v-text="todo.text"></li> | |
| </ul> | |
| <button @click="reverseMessage" v-text="tbuttons.title"></button> | |
| <button @click="reverseList" v-text="tbuttons.list"></button> | |
| <button @click="reverseEverythin" v-text="tbuttons.all"></button> | |
| </div> | |
| <body> | |
| <script type="text/javascript" src="https://vuejs.org/js/vue.min.js"></script> | |
| <script type="text/javascript"> | |
| const reverseIt = s => s.split('').reverse().join(''); | |
| new Vue({ | |
| el: '#app', | |
| data: { | |
| title: "Sample is here", | |
| tbuttons: { | |
| title: 'Reverse Title', | |
| list: 'Reverse List', | |
| all: 'Reverse Everythin' | |
| }, | |
| todos: [{ | |
| text: 'I am here' | |
| }, { | |
| text: 'she is here' | |
| }, { | |
| text: 'he is here' | |
| }, { | |
| text: 'we are here' | |
| }] | |
| }, | |
| methods: { | |
| reverseMessage: function() { | |
| this.title = reverseIt(this.title) | |
| }, | |
| reverseList: function() { | |
| this.todos.forEach(todo => todo.text = reverseIt(todo.text)) | |
| }, | |
| reverseEverythin: function() { | |
| this.reverseMessage(); | |
| this.reverseList(); | |
| Object.keys(this.tbuttons).forEach(button => this.tbuttons[button] = reverseIt(this.tbuttons[button])); | |
| } | |
| } | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here is the preview http://htmlpreview.github.io/?https://gist.githubusercontent.com/sonus/d3a847c293558ca8f87314ab5f926dd3/raw