类型错误 .join 不是函数 Netlify 构建错误
Type error .join not a function Netlify build error
大家好,我 运行遇到了一个错误,我不确定如何解决。我继承了一个项目,以前的开发人员只是想加入一个字符串数组。当我 运行 构建时,我在 Netlify 中收到以下错误。
TypeError: this.props.keywords.join 不是函数
下面是代码示例
content: this.props.keywords ? this.props.keywords.join(", ") : ""
this.props.keywords 有问题吗? this.props.keywords.join(", ") : "" 我只是没看到?
如有任何帮助,我们将不胜感激。
确保 this.props.keywords
是一个数组:
content: Array.isArray(this.props.keywords) ? this.props.keywords.join(", ") : ""
Array.isArray
的工作原理:
// all following calls return true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
Array.isArray(new Array('a', 'b', 'c', 'd'));
Array.isArray(new Array(3));
// Little known fact: Array.prototype itself is an array:
Array.isArray(Array.prototype);
// all following calls return false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray('Array');
Array.isArray(true);
Array.isArray(false);
Array.isArray(new Uint8Array(32));
Array.isArray({ __proto__: Array.prototype });
大家好,我 运行遇到了一个错误,我不确定如何解决。我继承了一个项目,以前的开发人员只是想加入一个字符串数组。当我 运行 构建时,我在 Netlify 中收到以下错误。
TypeError: this.props.keywords.join 不是函数
下面是代码示例
content: this.props.keywords ? this.props.keywords.join(", ") : ""
this.props.keywords 有问题吗? this.props.keywords.join(", ") : "" 我只是没看到?
如有任何帮助,我们将不胜感激。
确保 this.props.keywords
是一个数组:
content: Array.isArray(this.props.keywords) ? this.props.keywords.join(", ") : ""
Array.isArray
的工作原理:
// all following calls return true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
Array.isArray(new Array('a', 'b', 'c', 'd'));
Array.isArray(new Array(3));
// Little known fact: Array.prototype itself is an array:
Array.isArray(Array.prototype);
// all following calls return false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray('Array');
Array.isArray(true);
Array.isArray(false);
Array.isArray(new Uint8Array(32));
Array.isArray({ __proto__: Array.prototype });