我使用创建了一个反应项目
create-react-app react-app
Run Code Online (Sandbox Code Playgroud)
然后使用所有文件夹创建了一个反应应用程序。(使用 Visual Studio 代码)
然后使用rimraf删除“src”文件夹
然后打开index.html并删除其所有内容。
然后 !并在index.html中输入并创建HTML样板代码
然后在其中创建以下div,
<div id="root">
React Component goes here....
</div>
Run Code Online (Sandbox Code Playgroud)
现在创建了“src”文件夹,并在其中创建了包含以下内容的“index.js”,
import React from "react";
import ReactDOM from "react-dom";
import "../node_modules/bootstrap/dist/css/bootstrap.css";
import HelloComponent from "./components/helloComponent";
import BindingComponent from "./components/bindingComponent";
ReactDOM.render(
<React.Fragment>
<HelloComponent name={"Rohit"} />
<HelloComponent />
<BindingComponent></BindingComponent>
</React.Fragment>,
document.querySelector("#root")
);
Run Code Online (Sandbox Code Playgroud)
在“package.json”中,我在脚本部分有以下内容,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Run Code Online (Sandbox Code Playgroud)
还在组件文件夹中创建了 React Components
现在,当我运行 using 时npm start,它如何调用index.js ???
我想将日期转换为不同格式的字符串,但出现以下错误,
DateTimeException-Field DayOfYear cannot be printed as the value 234 exceeds the maximum print width of 2
Run Code Online (Sandbox Code Playgroud)
下面是不同的格式,
"MMDDYY"
"DD_MM_YY"
"YYYYMMDD"
"MMDD"
"DD-MM-YY"
Run Code Online (Sandbox Code Playgroud)
下面是我的代码,
LocalDate localDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("DD-MM-YY");
String formattToString = localDate.format(formatter);
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?
CONDITION1 和 CONDITION2 是字符串变量,可以是 NULL 或非 NULL。比如说我有 2 个变量,比如 CONDITION1 和 CONDITION2。如果 CONDITION1 不为 NULL,则调用 METHOD1(),如果它返回 TRUE,则检查 CONDITION2 是否为 NOT NULL,然后调用 METHOD2()。如果 CONDITION1 为 NULL,那么我检查 CONDITION2 是否为 NULL。如果它不是 NULL,那么我调用 METHOD2()。如果 CONDITION1 不是 NULL,那么我调用 METHOD1() 然后我检查 CONDITION2 是否为 NULL。如果它是 NULL 那么我不调用 METHOD2()。
两种方法都返回一个布尔值。对或错。
下面是使用 if else if 语句的代码。
有更好的方法吗?
//Fail并// process further表示相同的代码。
if(CONDITION1 != null && CONDITION2 …Run Code Online (Sandbox Code Playgroud)