tôi có mã này:phương pháp truy cập mẹ từ mẫu thành phần trong vuejs
new Vue({
el: '#app',
components: {
'app-component': AppComponent
},
data: {
message: 'Hello Vue.js!'
},
methods: {
doSomething: function(){
console.log('arrived!')
}
}
})
Làm thế nào tôi có thể gọi là "doSomething" phương pháp từ AppComponent html mẫu? như thế này:
<app-component>
<a href="#" v-on:click="doSomething()">text</a>
</app-component>
tôi nhận được lỗi này:
Uncaught TypeError: scope.doSomething is not a function
thử 'v-on: click = "doSomething" ' – maioman
@maioman Tôi nhận điều này: [Vue cảnh báo]: v-on: click = "doSomething" hy vọng một giá trị chức năng, đã không xác định (có trong thành phần :) –
saeedhbi