请参阅以下代码
render() {
const post = this.props.post;
let postClass = "posts-item";
if (post.sticky) postClass += " posts-sticky";
// ⭐ custom code starts here ⭐
if (post.color) {
postClass += " post-"+post.color;
}
// ⭐ custom code ends here ⭐
const currentUrl = window ? window.location.href : undefined;
.......
........
}
在此代码中,行const currentUrl = window ? window.location.href : undefined;
正在生成以下错误
url: /
{ [ReferenceError: window is not defined] queryErrors: [ [Circular] ] }
如何解决这个问题?
答案 0 :(得分:0)
我已通过以下代码修复此问题
let currentUrl;
if(Meteor.isClient)
currentUrl = window ? window.location.href : undefined;