Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在react js中从多个子页面隐藏页脚_Javascript_Reactjs - Fatal编程技术网

Javascript 在react js中从多个子页面隐藏页脚

Javascript 在react js中从多个子页面隐藏页脚,javascript,reactjs,Javascript,Reactjs,我想从多个子页面隐藏页脚,但当我使用 {window.location.pathname!==“/subpage1”&&&} {window.location.pathname!==“/subpage2”&&} 它不起作用,但当只使用其中一个时,它就起作用了。如何修复它?如果您想以与您尝试的相同方式使用它,您可以这样做。对于window.location.path,也会有同样的想法。将“val”替换为“window.location.path”变量。我想我的评论中有额外的曲线括号 返回( {

我想从多个子页面隐藏页脚,但当我使用

{window.location.pathname!==“/subpage1”&&&}
{window.location.pathname!==“/subpage2”&&}

它不起作用,但当只使用其中一个时,它就起作用了。如何修复它?

如果您想以与您尝试的相同方式使用它,您可以这样做。对于window.location.path,也会有同样的想法。将“val”替换为“window.location.path”变量。我想我的评论中有额外的曲线括号

返回(
{val[0]==1 | | val[1]==2?:null}
);
};
就你的情况而言,应该是:

{ window.location.pathname === "/subpage1" || window.location.pathname === "/subpage2" ? null : <footer /> }
{window.location.pathname==”/subpage1“| | window.location.pathname==”/subpage2”?空:}

正如我提到的,我只是给了你基本的想法。这只是一个条件语句。

您不能将两者合并为一个吗?类似于{((window.location.pathname!==“/subpage1”)| |(window.location.pathname!==“/subpage2”)?:null}您的代码不起作用,但我们可以尝试不同的suntaxe?我不明白在您的语法中我应该将子页面1和子页面2放在哪里?
{ window.location.pathname === "/subpage1" || window.location.pathname === "/subpage2" ? null : <footer /> }