小编rav*_*l91的帖子

Java Browser Plugin或手动安装Java

这是我的问题,我安装了谷歌Java插件,它确实意味着我已经在我的机器上安装了Java ...安装此插件后,我可以在命令下运行

java -jar myfile.jar
Run Code Online (Sandbox Code Playgroud)

通过批处理文件或我必须在我的机器上安装java并设置class-path然后它应该工作?

如果我将安装Java浏览器插件,它也会在我的机器和设置路径中自动安装java.

我很难理解它的工作原理.谁可以帮我这个事?

java installation plugins

5
推荐指数
1
解决办法
502
查看次数

React JSX 未被识别?

我正在使用这 2 个 CDN 在我的项目中包含 React 库,但是当我使用 JSX 将一些 html 渲染到 HTML 文档的主体上时,它不会将 JSX 识别为 JSX(我正在使用 chrome),因此抛出当它将 JSX 读取为 javascript 时出现错误。难道我做错了什么?任何帮助都会很棒:) CDN:

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
Run Code Online (Sandbox Code Playgroud)

HTML:

<body>
   <div id="here"></div>  
</body>
Run Code Online (Sandbox Code Playgroud)

反应:

var React = require('react');
var ReactDOM = require('react-dom');
const text = <h1>Hello World</h1>;

ReactDOM.render(text, document.getElementById('here'));
Run Code Online (Sandbox Code Playgroud)

html javascript reactjs

5
推荐指数
1
解决办法
6168
查看次数

生命周期方法和 useEffect 钩子有什么区别?

在 Components 类中,我们使用 componentDidMount、componentDidUpdate 生命周期方法来更新状态。前任)

componentDidMount() {
    document.title = `You clicked ${this.state.count} times`;
}

componentDidUpdate() {
    document.title = `You clicked ${this.state.count} times`;
}
Run Code Online (Sandbox Code Playgroud)

它在每次渲染(componentDidUpdate)之后运行,包括第一次渲染(componentDidMount)。在 useEffect 钩子中,我们可以像这样实现这个功能

useEffect(() => {
    document.title = `You clicked ${count} times`;
});
Run Code Online (Sandbox Code Playgroud)

这2种方法效果一样吗?

我读了 Reactjs.org 的这一部分,并且在 React.js vs 16 上尝试过。我认为这两种方法具有相同的效果。

useEffect(() => {
    document.title = `You clicked ${count} times`;
});
Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

5
推荐指数
1
解决办法
1万
查看次数

React Arrow Function Component - setState is not defined

I am trying to setState in an arrow function component but getting an error "setState is not defined".

I tried setting state in handleChange using setState({ selectedSlot }) and this.setState({ selectedSlot }) but nothing worked.

 const AddAssetActivity = props => {
 let { variations, slots, priceStructure } = props;

 let state = {
   selectedSlot: { "0": "00", "1": "11" },
   cal: 1
 };

 let handleChange = (event, value) => {
   let selectedSlot = state.selectedSlot;
   selectedSlot[value.variation] = value.slot;
   setState({ selectedSlot }); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs arrow-functions

5
推荐指数
1
解决办法
285
查看次数

Input type="file" showing weird behavior when used along with another input type

I have an input type="file" and an input type="text". When I choose the file first and then put text in the input box and click the Add button, the picture doesn't show but when I put the text first and then choose the picture (file), it behaves normally.I think there's some problem in the inputKey That I have given. Here's a link from where I found this method http://robhoffmann.me/2016/03/12/Clearing-a-file-input-in-React/

What I am trying to do: I want to be …

javascript debugging input-type-file reactjs

5
推荐指数
1
解决办法
49
查看次数

有序列表在firefox 57中没有增加

我在Firefox 57中遇到了一个问题,其中包含html中的有序列表.

html是动态生成的,但示例如下所示:

<ol>
  <li>ashdg</li>
  <li>ashdg</li>
  <li>ashdg</li>
</ol>
Run Code Online (Sandbox Code Playgroud)

它有以下CSS

ol{
    margin-top: 0px !important;
    margin-bottom: 0px !important;
    list-style-type: decimal !important;
    list-style-position: inside !important;
}

p, ul, ol {
    padding: 0;
    margin: 0;
    display: inline;
}
Run Code Online (Sandbox Code Playgroud)

firefox输出

FireFox输出

Chrome输出

在此输入图像描述

html css firefox

4
推荐指数
1
解决办法
141
查看次数

Reactjs 滚动多个引用

我对reactjs中的ref有疑问。抱歉,这很愚蠢,但我仍在学习。好吧,问题是我正在尝试滚动以使用 ref 做出反应,但我的问题是因为我想使用多个引用。

我的代码是这样的:

import React, { Component } from "react";
import './App.css';
import { Row, Col,Image,ListGroup,Button,Jumbotron,Container} from 'react-bootstrap';



class App extends Component {

  constructor(props) {
    super(props)
    this.myRef = React.createRef()
    this.myRef2 = React.createRef()    // Create a ref object 
}


handleOnClick = (event) => {
  //.current is verification that your element has rendered

  window.scrollTo(2, this.myRef2.current.offsetTop) 
}


  render() {


    return (
    <div className="App">
             <button onClick={this.handleOnClick}>Click me</button>

      <Row>
        <Col className="menu text-center" lg ={4}>

          <div className="picture" >
            <Image src={process.env.PUBLIC_URL + '/Images/picture.jpg'} roundedCircle />
          </div> …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

4
推荐指数
1
解决办法
4509
查看次数

使用 React.lazy() 时开发构建崩溃

我正在使用 react Lazy 和 Suspense 来加载组件,但是如果我尝试使用npm run build 构建应用程序,我会收到一条错误消息:错误:未捕获的错误:最小化的响应错误 #294;,而且如果我评论延迟加载,构建就会成功。代码:

import { Suspense, lazy } from 'react';
const Component= lazy(() => import('./../location'));

const Homepage=()=>{
  return (
    <>
      <Suspense fallback={<div>Loading...</div>}>                
        <Component/>
      </Suspense>
    </>
  )
}
export default Homepage;
Run Code Online (Sandbox Code Playgroud)

reactjs react-router react-hooks

4
推荐指数
2
解决办法
5008
查看次数

无法使用React Native单击animated.view中的TouchableOpacity

我无法点击TouchableOpactity进去Animated.View。你能帮助我吗?

<Animated.View>
    <TouchableOpacity>
        <Text>Click Me!!</Text>
    </TouchableOpacity>
</Animated.View>
Run Code Online (Sandbox Code Playgroud)

react-native

3
推荐指数
1
解决办法
4867
查看次数

错误:输入是一个空元素标签,不能有 `children` 也不能使用 `dangerouslySetInnerHTML`

import React , { Component } from 'react'

class Login extends Component{
    constructor(props){
        super(props)

    }
    render(){
        return(
            <form className="login-form">
                <h1>login</h1>
                <div>
                    <div className="form-group">
                        <label for="name">
                            Name :
                        </label>
                        <input name="name" type="text" value="" placeholder="Your Name" />
                    </div>
                    <div className="form-group">
                        <label for="password">
                            Password :
                        </label>
                        <input name="password" type="Password" value="" placeholder="Password" />
                    </div>
                    <input type="submit">Submit</input>
                </div>
            </form>
        )
    }
}

export default Login
Run Code Online (Sandbox Code Playgroud)

jsx reactjs

3
推荐指数
1
解决办法
5820
查看次数