【发布时间】:2015-09-16 21:21:51
【问题描述】:
我有一个问题,将函数传递给组件没有按照文档中指定的方式工作。
这是在我的 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
任何帮助将不胜感激:)
【问题讨论】:
标签: javascript vue.js