我有一個問題,即將函數傳遞給組件的方式與文檔中指定的方式不一致。Vue.js將函數傳遞給不工作的道具
這是我app.js
methods: {
updateAnswer: function(question) {
console.log('question: '+question);
}
}
這是我的html文件:
<multiplechoice class="question counterIncrement counterShow active" id="q2" whenanswered="{{ updateAnswer('1') }}"></multiplechoice>
這是我components.js文件:
props: [
'whenanswered'
],
ready: function() {
this.whenanswered();
},
我已經試過這個:
props: [
{ name: 'whenanswered', type: Function}
];
但仍然沒有運氣。
這是我的控制檯當我加載的頁面:
Uncaught TypeError: this.whenanswered is not a function
任何幫助將是非常讚賞:)