在 React 中使用 Typescript 时,我们必须jsx在文件compilerOptions中指定tsconfig.json。
它有preserve、react、react-native等react-jsx作为允许值。
{
"compilerOptions": {
"jsx": "react-jsx" | "react" | "react-native" | "preserve"
}
}
Run Code Online (Sandbox Code Playgroud)
react主要react-jsx用于网络我想了解这两个选项之间的区别以及何时选择哪一个
react将 jsx 翻译为React.createElement()
react-jsx将 jsx 翻译为_jsx()and_jsxs()
_jsx()还有和之间有什么区别_jsxs()?
我在bitbucket上设置了一个git存储库
$ git remote -v
origin https://myusername@bitbucket.org/myusername/my_repository_name.git (fetch)
origin https://myusername@bitbucket.org/myusername/my_repository_name.git (push)
Run Code Online (Sandbox Code Playgroud)
我从办公室工作站和家用电脑上拉到存储库.当我从办公室工作站推或拉时,它会提示我输入密码.但是,当我从家用电脑推或拉时,它不会提示输入密码.
我不记得我在家用电脑上做了什么来记住密码.
跑步$ git config credential.helper回报manager
$ git config credential.helper
manager
Run Code Online (Sandbox Code Playgroud)
根目录下的.gitconfig用户文件夹中的内容文件
[user]
name = myusername
email = user.name@email.com
Run Code Online (Sandbox Code Playgroud)
密码存储在本地磁盘上的哪个位置?
检查当前凭据状态的命令是什么?
我如何同样记住办公室工作站上的密码?
注意:我使用的是Windows 7
我跑了npm install prop-types --save-dev
并开始收到此错误
'prop-types' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
后来我通过运行卸载了依赖项npm uninstall prop-types --save-dev并通过运行再次安装npm install prop-types --save
错误仍然没有消失
'prop-types' should be listed in the project's dependencies. Run 'npm i -S prop-types' to add it import/no-extraneous-dependencies
我有一个如下样式的组件
const StyledCustomComponent = styled.aside`
min-width: ${gridPts(19)};
background-color: ${HIGHLIGHT_BLUE};
flex: 0 0 auto;
${fontSize(13)}
padding: ${gridPts(2)};
@media only screen and (max-width: ${MQ_320}) {
padding: ${gridPts(1)};
}
@media only screen and (min-width: ${MQ_1285}), (min-width: ${MQ_575}) and (max-width: ${MQ_961}) {
&:first-child {
margin-top: 0;
}
}
`
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中检查它并调整大小以匹配媒体查询时,:first-child 样式不适用。
上述组件的子组件的样式如下
const StyledCustomComponentChild = css`
margin: ${gridPts(1)} ${gridPts(1)} 0;
@media only screen and (max-width: ${MQ_575}), (min-width: ${MQ_961}) and (max-width: ${MQ_1285}) {
display: inline-block;
float: left;
margin-right: ${gridPts(1)};
& * {
display: inline-block;
margin-right: …Run Code Online (Sandbox Code Playgroud) 我需要对状态变化进行API调用
我应该使用哪种生命周期方法进行此API调用?
componentDidUpdate(),getDerivedStateFromProps()或任何其他?
什么是最佳做法?
<!DOCTYPE html>
<html>
<body>
<p id="demo1"></p>
<p id="demo2"></p>
<script>
var status = [true,false,true,false,true,false,true,false,true,false];
var status1 = [true,false,true,false,true,false,true,false,true,false];
document.getElementById("demo1").innerHTML = status[2];
document.getElementById("demo2").innerHTML = status1[2];
</script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
https://jsfiddle.net/vdr2r38r/
为什么不同名称的相同变量的行为不同?
我安装create-react-app没有-g
C:\Users\user1\projects\react>npm install create-react-app
但是当我跑
C:\Users\user1\projects\react>create-react-app my-app1
我收到以下错误
'create-react-app' is not recognized as an internal or external command, operable program or batch file.
任何人都可以帮我理解-g旗帜的作用
如果我不想全局安装怎么办?
如何在没有全局安装的情况下使其工作?
我正在将应用程序的样式从 Less 转换为Emotion
在 Less 我有如下样式:
@blue: #476882;
background: rgba(red(@blue), green(@blue), blue(@blue), 0.5);
Run Code Online (Sandbox Code Playgroud)
在转换为情感时,我正在这样做:
export const BLUE = '#476882'
background: rgba(red(${BLUE}), green(${BLUE}), blue(${BLUE}), 0.5);
Run Code Online (Sandbox Code Playgroud)
但是它不起作用。
有什么建议可以使这项工作?
我有一个在路由上加载的React组件
我需要从组件构造函数中的url访问参数
我该怎么做?
我可以这样访问吗:
class CustomCoponent extends React.Component {
constructor(props,{match}) {
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个像我的应用程序中一样的小子窗口div,我需要在子窗口内显示模式而不是整个视口。
所以模态的背景应该只覆盖子窗口而不是整个屏幕
我使用的是material-ui,因此首选任何material-ui 原生的解决方案。
reactjs ×8
javascript ×3
css ×2
credentials ×1
emotion ×1
git ×1
jsx ×1
less ×1
material-ui ×1
modal-dialog ×1
npm-install ×1
react-router ×1
typescript ×1