Created
May 2, 2016 18:24
-
-
Save zfedoran/0c8d0c06d72263ec562aef7360c28a6f to your computer and use it in GitHub Desktop.
Simple Vue.js Example (no build tools)
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
<!-- Live Example: https://jsfiddle.net/Lqn6ocqm/ --> | |
<component> | |
<style> | |
.zelimir div { | |
background: #0ff; | |
} | |
</style> | |
<template> | |
<div class="zelimir"> | |
<div>Zelimir Says: {{ number }} </div> | |
</div> | |
</template> | |
<script> | |
var el = document.currentScript; | |
Vue.component('zelimir', { | |
data: function() { | |
return { | |
number: Math.random() | |
} | |
}, | |
created: function() { | |
}, | |
template: el.parentElement.querySelector('template') | |
}); | |
</script> | |
</component> | |
<component> | |
<style> | |
.joost div { | |
background: #eee; | |
} | |
</style> | |
<template> | |
<div class="joost"> | |
<div>Joost Says: {{ time }} </div> | |
<zelimir v-for="v in [1,2,3,4]"></zelimir> | |
</div> | |
</template> | |
<script> | |
var el = document.currentScript; | |
Vue.component('joost', { | |
data: function() { | |
return { | |
time: new Date() | |
} | |
}, | |
created: function() { | |
var self = this; | |
setInterval(function() { | |
self.time = new Date(); | |
}, 100); | |
}, | |
template: el.parentElement.querySelector('template') | |
}); | |
</script> | |
</component> | |
<div id="app"> | |
<joost></joost> | |
</div> | |
<script> | |
new Vue({ | |
el: '#app' | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://jsfiddle.net/Lqn6ocqm/