Skip to content

Instantly share code, notes, and snippets.

@takaheraw
Created September 30, 2018 01:22
Show Gist options
  • Save takaheraw/70e91b56b2df9d15db224f68aabcfe26 to your computer and use it in GitHub Desktop.
Save takaheraw/70e91b56b2df9d15db224f68aabcfe26 to your computer and use it in GitHub Desktop.
vue component
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<div id="login-example">
<user-login></user-login>
</div>
<script type="text/x-template" id="login-template">
<div id="login-template">
<div>
<input type="text" placeholder="ログインID" v-model="userid">
</div>
<div>
<input type="password" placeholder="パスワード" v-model="password">
</div>
<button @click="login()">ログイン</button>
</div>
</script>
<script>
Vue.component('user-login', {
template: '#login-template',
data: function() {
return {
userid: '',
password: ''
}
},
methods: {
login: function() {
auth.login(this.userid, this.password)
}
}
})
var auth = {
login: function(id, pass) {
window.alert("userid:" + id + "\n" + "password:" + pass);
}
}
new Vue({
el: "#login-example"
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment