HTML:<ul> <item v-on:click="boom" v-bind:product="item" v-bind:key="item.id" v-for="item in items" ></item></ul>Javascript:Vue.component('item', { props: ['product'], template: '<li><a href="#">{{ product.name }}</a></li>',});let app = new Vue({ el: 'ul', data: { items: [ { id: 0, name: 'penda' }, { id: 1, name: 'harla' }, { id: 2, name: 'calar' }, ], }, methods: { boom: function (e) { alert('Aha!'); } }});一切都呈現(xiàn)良好,但boom事件監(jiān)聽器永遠(yuǎn)不會觸發(fā)。你知道原因嗎?
點(diǎn)擊事件監(jiān)聽器不適用于VueJS中的組件
SMILET
2021-03-29 17:09:36