Skip to content

Instantly share code, notes, and snippets.

@kitak
Created December 19, 2016 10:01
Show Gist options
  • Save kitak/1145eb4e16980c6b9fb64ffda99255ce to your computer and use it in GitHub Desktop.
Save kitak/1145eb4e16980c6b9fb64ffda99255ce to your computer and use it in GitHub Desktop.
Vueの算出プロパティの検証
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="node_modules/vue/dist/vue.js"></script>
<script>
var vm;
document.addEventListener('DOMContentLoaded', () => {
vm = new Vue({
el: '#app',
data: function () {
return {
prefix: 'Hello',
firstName: 'kita',
lastName: 'keisuke'
};
},
computed: {
fullName: function () {
return this.firstName + ' ' + this.lastName;
},
greeting: function () {
return this.prefix + ', ' + this.fullName;
}
}
});
});
</script>
</head>
<body>
<div id="app">
<p>{{ firstName }}</p>
<p>{{ fullName }}</p>
<p>{{ greeting }}</p>
</div>
</body>
</html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment