Skip to content

Instantly share code, notes, and snippets.

@tsukiyama-a5
Created November 19, 2019 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsukiyama-a5/fa6ce08b6240e1b47073c4d0240bf5d2 to your computer and use it in GitHub Desktop.
Save tsukiyama-a5/fa6ce08b6240e1b47073c4d0240bf5d2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="app">
従業員番号:<input type="text" v-model="empid" placeholder="1,2,3のどれか"><br>
{{empname}}<br>
</div>
<script src="https://jp.vuejs.org/js/vue.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
name: '',
empid: ''
},
computed: {
empname: function() {
console.log(this.empid);
switch (this.empid) {
case '1':
this.name = 'takahashi';
break;
case '2':
this.name = 'higashiguchi';
break;
case '3':
this.name = 'taniguchi';
break;
default:
this.name = '';
break;
}
return this.name + ':' + this.empid;
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment