Skip to content

Instantly share code, notes, and snippets.

@kklecho
Created December 8, 2019 23:46
Show Gist options
  • Save kklecho/e8fbcfe0164f4e31637ea36a78c1caf3 to your computer and use it in GitHub Desktop.
Save kklecho/e8fbcfe0164f4e31637ea36a78c1caf3 to your computer and use it in GitHub Desktop.
#assets/js/components/App.vue
<template>
<div>
<h2 class="center">My Application</h2>
<div v-text="message"></div>
{{ message }}
<ul>
<li :key="word.id" v-for="word in words">{{ word }}</li>
</ul>
</div>
</template>
<script>
export default {
data() {
return {
message: "A list of words",
words: []
};
},
mounted() {
let el = document.querySelector("div[data-words]");
let mywords = el.dataset.words.split(",");
this.words.push.apply(this.words, mywords);
}
};
</script>
<style>
.center {
text-align: center;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment