我已经看到了有关此问题的几个问题,但没有一个问题可以帮助我解决我的问题。我有一个父组件和三个子组件。
import React, { Component } from 'react'
import Header from "./Header";
import ChildOne from "./ChildOne"
import ChildTwo from "./ChildTwo"
class Parent extends Component {
render() {
return (
<div>
<Header />
<ChildOne />
<ChildTwo />
</div>
)
}
}
export default Parent;
Run Code Online (Sandbox Code Playgroud)
每个子组件都包含一个简单的div. 我已将以下样式应用于组件:
.header {
position: relative;
width: 100%;
height: 100px;
}
.childone {
width: 100%;
height: 480px;
position: absolute;
top: auto;
}
.childtwo {
width: 100%;
height: 240px;
position: absolute;
top: auto;
}
Run Code Online (Sandbox Code Playgroud)
我希望 React …
我有一个NavbarReact 组件,其中一个Link组件需要在单击时向下滚动到Section组件。我已经实现了react-scroll,但是,当我单击该Link组件时,我会target element not found进入浏览器控制台。
导航栏组件:
import React, { Component } from "react";
import { Link, animateScroll as scroll, scroller } from "react-scroll";
class Navbar extends Component {
render() {
return (
<div>
<ul>
<li>
<Link to="section1" activeClass="active" spy={true} smooth={true}>
Section 1
</Link>
</li>
</ul>
</div>
);
}
}
export default Navbar;
Run Code Online (Sandbox Code Playgroud)
以及 App.js 文件:
import React from "react";
// Styling
import "./styles/App.css";
// Components
import Navbar from …Run Code Online (Sandbox Code Playgroud) 我猜我对polyfill有一个奇怪的问题。我为应用程序使用了MERN堆栈,然后推送到Heroku。由于某些原因,我可以在Chrome的计算机上查看该网站,但是,在其他计算机上却出现空白页和控制台错误:
'SCRIPT5007: Unable to get property 'apply' of undefined or null reference'
Run Code Online (Sandbox Code Playgroud)
它指向这段代码,并且显然链接到Redux:
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
};
});
}
Run Code Online (Sandbox Code Playgroud)
我将babel-polyfill导入了我的App.js文件,甚至添加了<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es6"></script></script>,index.html但还是没有运气。如何解决这个问题?
UPD:看来原因是Redux Dev Tools。我需要以某种方式在生产中禁用它。