Created
September 30, 2018 01:22
-
-
Save takaheraw/70e91b56b2df9d15db224f68aabcfe26 to your computer and use it in GitHub Desktop.
vue component
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://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