Created
September 28, 2016 20:59
-
-
Save colynb/51b3cdb132ee1cc2177987de4afcfcd7 to your computer and use it in GitHub Desktop.
VueJS Server Rendering Test
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"> | |
<ul> | |
<li v-for="option in options"> | |
<span class="red">{{ option.text }}</span> | |
</li> | |
</ul> | |
<ul v-if="!fetched"> | |
<li>One</li> | |
<li>Two</li> | |
<li>Three</li> | |
</ul> | |
</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', | |
created: function() { | |
this.fetchData() | |
}, | |
methods: { | |
fetchData: function(cb) { | |
// simulate ajax call | |
setTimeout(function() { | |
this.fetched = true | |
this.options = [ | |
{ | |
text: "One" | |
}, | |
{ | |
text: "Two" | |
}, | |
{ | |
text: "Three" | |
} | |
]; | |
}.bind(this), 1000); | |
} | |
}, | |
data: { | |
fetched: false, | |
options: [] | |
} | |
}) |
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://cdnjs.cloudflare.com/ajax/libs/vue/1.0.27/vue.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> |
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
.red { | |
color: #f00; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment