Created
December 6, 2018 05:35
-
-
Save kai-kou/9b5b613918e107ca23682982c75d9467 to your computer and use it in GitHub Desktop.
Vue.jsでコンポーネントのイベント名をキャメルケースにすると反応しない
This file contains 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
<html> | |
<body> | |
<div id="app"> | |
<custom-component | |
:msg='msg' | |
v-on:hello-hoge="msg = 'OK!!!'" | |
v-on:helloHoge="msg = 'OK???'" | |
/> | |
</div> | |
<script type="text/x-template" id="custom-component"> | |
<div> | |
<span>{{msg}}</span> | |
<button v-on:click="$emit('hello-hoge')">これはOK!</button> | |
<button v-on:click="$emit('helloHoge')">これはだめ!</button> | |
</div> | |
</script> | |
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script> | |
<script> | |
Vue.component("customComponent", { | |
props: ["msg"], | |
template: "#custom-component", | |
}) | |
</script> | |
<script> | |
new Vue({ | |
el: "#app", | |
data: { | |
msg: 'hoge' | |
}, | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment