我试图将用户输入限制为仅字母,但由于某种原因它不起作用。我对 ReactJS 很陌生,所以也许我的问题出在某个地方。这是我到目前为止所得到的:
<input type="text" pattern="[a-zA-Z]*" placeholder="Add Skill" onChange={this.updateField} />
Run Code Online (Sandbox Code Playgroud)
type="text" 和 pattern 在这种情况下似乎不起作用。
提前致谢!
我目前的配置是:
"@vue/test-utils": "^1.0.0-beta.25"
Run Code Online (Sandbox Code Playgroud)
如何在仍然使用插入符号的同时排除此包的特定版本^?
我想排除的版本是1.0.0-beta.31,因为这个版本目前破坏了我的整个测试。
我是 React 的新手,正在尝试使用嵌套路由创建布局。这是我的场景
在浏览器中访问 URL 时,登录页面和仪表板页面会正确加载,但对于 /dashboard/profile,浏览器会转到空白页面,而不是将其加载到仪表板组件中。
索引.js
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)
应用程序.js
class App extends Component {
render() {
return (
<div>
{/* <Switch> */}
<Route exact path='/' component={SignIn}/>
<Route exact path='/dashboard' component={Dashboard}/>
{/* </Switch> */}
</div>
);
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
仪表板.js
class Dashboard extends React.Component {
render() {
const { classes } = this.props;
return (
<React.Fragment>
<CssBaseline /> …Run Code Online (Sandbox Code Playgroud) 我正在使用React with react-redux和redux-actions.
我有以下减速机一直告诉我
意外的令牌,预期","
但我不确定为什么.
comments.js (reducer):
import { handleActions } from "redux-actions";
import {
GET_COMMENTS,
SET_COMMENTS,
ADD_COMMENT
} from "../constants/actionTypes";
export default handleActions(
{
[GET_COMMENTS]: (state, action) => state,
[ADD_COMMENT]: (state, action) => {
const comments = {
...state.comments,
action.payload
};
return {
...state,
comments
};
},
[SET_COMMENTS]: (state, action) =>
Boolean(action.payload) ? action.payload : state
},
{}
);
Run Code Online (Sandbox Code Playgroud)
导致麻烦的动作是ADD_COMMENT.我尝试过以下几种方法:
[ADD_COMMENT]: (state, action) => {
...state,
comments: {
...state,
action.payload
}
}
Run Code Online (Sandbox Code Playgroud)
要么
[ADD_COMMENT]: (state, action) …Run Code Online (Sandbox Code Playgroud) 我正在通过 Symfony Bundle knp Snappy bundle使用 wkhtmltopdf ,只要我使用 px 作为大小,它就可以正常工作。但是我需要根据 A4 尺寸生成一张贴纸,但我什么都做不了:我将 wkhtmltopdf 的所有边距设置为 0
$snappy->setOption('margin-top', '0mm');
$snappy->setOption('margin-left', '0mm');
$snappy->setOption('margin-right', '0mm');
$snappy->setOption('margin-bottom', '0mm');
Run Code Online (Sandbox Code Playgroud)
然后在我的测试 html(它是应用程序中的一根树枝)中的一列:我尝试了一个简单的:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
</head>
<body style="margin:0;padding:0">
<div style="background-color:red;width:99%;height:1400px;border:solid #000 1px">
<div style="background-color:green;display:inline-block;padding:0;margin:0;width:105mm;height:297mm"></div>
<div style="background-color:yellow;display:inline-block;padding:0;margin:0;width:105mm;height:297mm"></div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我也试过英寸:105 => 4.13in, 297mm => 11.69in,结果相同
我也试过直接生成(没有包)
wkhtmltopdf --page-size A4 -B 0 -L 0 -R 0 -T 0 test.html output.pdf
Run Code Online (Sandbox Code Playgroud)
结果相同
为什么 A4 尺寸的一半:105 毫米或 4.13 英寸不起作用?我也试过在 wkhtmltopdf 设置中直接设置页面大小:页面高度和页面宽度而没有改变。
我不能使用百分比,因为使用真实数据我会有更复杂的设置(左右边距、2、3...列)
设置可能有什么问题?这是一个CSS问题吗?wkhtmltopdf 问题?
我正在尝试侦听 Azure 服务总线队列,但在初始化与队列的连接时遇到异常。我试图寻找出路,但收效甚微。请注意,我使用的是 .NETCore 2.1。这是初始化连接的方式:
// Initialize the connection to Service Bus Queue
_queueClient = QueueClient.CreateFromConnectionString(_interswitchQueueConnectionString, _interswitchQueueName, ReceiveMode.ReceiveAndDelete);
Run Code Online (Sandbox Code Playgroud)
这是例外:
System.TypeInitializationException:“Microsoft.ServiceBus.Messaging.Constants”的类型初始值设定项引发异常。---> System.TypeLoadException: 无法从程序集“System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”加载类型“System.UriTemplate”。在 Microsoft.ServiceBus.Messaging.Constants..cctor() --- 内部异常堆栈跟踪结束 --- 在 Microsoft.ServiceBus.ServiceBusConnectionStringBuilder..ctor() 在 Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(String connectionString,字符串路径,ReceiveMode 模式)
使用 .net 框架时,相同的初始化工作正常。我怎样才能在 .NetCore 中做到这一点?请帮助提前致谢
是否有声明的任何区别state,从构造的?
我这里有一个组件示例:
class BurgerBuilder extends Component {
state = {
ingredients: {
salad: 0,
bacon: 0,
cheese: 0,
meat: 0
},
totalPrice: 30
};
....
}
Run Code Online (Sandbox Code Playgroud)
这里我只是声明了一个叫做state的变量,里面包含了组件的变量,但是我没有调用构造函数。
正如我声明的那样:
class BurgerBuilder extends Component {
constructor() {
super();
this.state = {
ingredients: {
salad: 0,
bacon: 0,
cheese: 0,
meat: 0
},
totalPrice: 30
};
}
....
}
Run Code Online (Sandbox Code Playgroud)
我发现,我可以this.setState用于这两种解决方案,并且我的项目没有真正的区别。是否有最佳实践,在什么地方使用什么。
使用NextJS,并看到了一个页面示例:
class IndexPage extends Component {
static async getInitialProps(context) {
return {};
}
render() {
return <div>hello world</div>;
}
}
export default withRouter(IndexPage);
Run Code Online (Sandbox Code Playgroud)
NextJS中的getInitialProps方法到底是什么?
我正在尝试使用光线投射旋转游戏对象。当我运行 Unity 编辑器时出现错误
ArgumentException:索引越界。UnityEngine.Input.GetTouch(Int32索引)(位于/Users/builduser/buildslave/unity/build/artifacts/ generated/bindings_old/common/Core/InputBindings.gen.cs:619)AdjustTransform.Update()(位于Assets/AdjustTransform) .cs:27)
第 27 行
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
位于下面的代码中。我在这里做错了什么?
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
if (Physics.Raycast(ray,out hit,100))
{
Debug.Log(" GO Name "+hit.collider.gameObject.name);
}
if( Input.touchCount == 2 && !EventSystem.current.IsPointerOverGameObject() )
{
hit.collider.gameObject.transform.Rotate(Vector3.up, -touchDeltaPosition.x * rotspeed * Time.deltaTime, Space.World);
hit.collider.gameObject.transform.Rotate(Vector3.right, touchDeltaPosition.y * rotspeed * Time.deltaTime, Space.World);
}
Run Code Online (Sandbox Code Playgroud) reactjs ×5
c# ×2
javascript ×2
.net-core ×1
azure ×1
components ×1
css ×1
next.js ×1
node.js ×1
npm ×1
react-redux ×1
react-router ×1
redux ×1
state ×1
vue.js ×1
wkhtmltopdf ×1