Created
August 28, 2017 16:02
-
-
Save lshapz/fabe516b720bdfb9099b811ee64a7f33 to your computer and use it in GitHub Desktop.
vue data binding and components
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
| <style> | |
| ul { | |
| list-style-type: none; | |
| } | |
| </style> | |
| <div id="app"> | |
| <component :is="currentView"></component> | |
| <ul> | |
| <li role="presentation"> | |
| <a href="#" @click="currentView='my-component'">SHOW KITTY</a> | |
| </li> | |
| <li role="presentation"> | |
| <a href="#" @click="currentView='your-component'">SHOW PUPPY</a> | |
| </li> | |
| </ul> | |
| <div> | |
| <input type="text" v-model="input_val"> | |
| Input Value: <span v-text="input_val"></span> | |
| </div> | |
| </div> | |
| <script src="https://unpkg.com/vue"></script> | |
| <script> | |
| Vue.component('my-component', { | |
| template: '<div><h1>{{message}}</h1><iframe width="560" height="315" src="https://www.youtube.com/embed/zusn3JtpFDk" frameborder="0" allowfullscreen></iframe></div>', | |
| data: function(){ | |
| return { | |
| message: "LOOK AT THIS CAT" | |
| } | |
| } | |
| }) | |
| Vue.component('your-component', { | |
| template: '<div><iframe width="560" height="315" src="https://www.youtube.com/embed/LaYPWtNvJ-A" frameborder="0" allowfullscreen></iframe><h1>{{message}}</h1></div>', | |
| data: function(){ | |
| return { | |
| message: "LOOK AT THAT DOG" | |
| } | |
| } | |
| }) | |
| new Vue({ | |
| el: '#app', | |
| data: { | |
| currentView: "my-component", | |
| input_val: "fishes?" | |
| } | |
| }) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment