【发布时间】:2015-08-05 02:56:22
【问题描述】:
我正在尝试从 getDefaultProps 访问 mixin 中定义的函数,但我得到了 undefined is not a function。基本上我正在使用react-intl 并且我的列的默认标签应该被翻译。为什么我无法从 getDefaultProps 中访问 mixin 中定义的函数?
var React = require('react');
var ReactIntl = require('react-intl');
var IntlMixin = ReactIntl.IntlMixin;
var Index = React.createClass({
mixins: [IntlMixin],
getDefaultProps: function () {
return ({
options: {
attributes: [{name: 'name', label: this.getIntlMessage('Index.name'), index: 0}],
view: "tiles"
}
});
},
render: function() {
return <div>{this.props.options.attributes[0].label}</div>
}
});
module.exports = Index;
【问题讨论】:
标签: javascript node.js reactjs mixins