Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vue.jsでコンポーネントのイベント名をキャメルケースにすると反応しない
<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
You can’t perform that action at this time.