我是React的新手,并且正在尝试使用yup进行验证.我目前收到以下错误:
TypeError:无法读取未定义的属性"对象"
使用此代码:
validationSchema: Yup.object().shape({
firstName: Yup.string().required()
}),
Run Code Online (Sandbox Code Playgroud)
我正在使用所有最新版本的formik,react和yup.版本是
"是":"^ 0.25.1""formik":"^ 0.11.11","反应":"^ 16.4.0","react-dom":"^ 16.4.0",
有人可以帮我解决这个问题吗?
它在这里复制 https://codesandbox.io/s/lrowpj8pq7
谢谢!
我正在使用Django,python,virtualenv,virtualenvwrapper和Vagrant.
到目前为止,我只是secret_key
将settings.py
文件留在文件内部.这适用于本地文件.但是我已经将我的文件放在Git中了.我知道这对于生产来说是不可接受的(Apache).
隐藏我的正确方法是什么secret_key
?
我应该virtualenv
用来隐藏吗?
我正在研究一个反应应用程序,如果用户的旧浏览器不支持(例如IE 9),客户希望它显示特殊消息.
很长一段时间我试图使用react-device-detect
包来检测一些"流行的"旧浏览器.
SRC/index.js
import { browserName, browserVersion } from "react-device-detect";
const render = Component => {
if (browserName === "IE" && browserVersion < 10) {
ReactDOM.render(<UnsupportedBrowser />, document.getElementById("root"));
} else {
ReactDOM.render(
<AppContainer>
<Component store={store} history={history} />
</AppContainer>,
document.getElementById("root")
);
}
};
Run Code Online (Sandbox Code Playgroud)
并提出条件评论:
公共/ index.html的
<!--[if lte IE 9]>
Please upgrade your browser
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
但我怀疑,有更好的方法,我找不到搜索网络.
我有一个对象数组,我想将它们写入文本文件中。这样我以后就可以读回数组中的对象。我该怎么做? 使用序列化。
反序列化不起作用:
public static void readdata(){
ObjectInputStream input = null;
try {
input = new ObjectInputStream(new FileInputStream("myfile.txt")); // getting end of file exception here
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
array = (players[]) input.readObject(); // null pointer exception here
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
readdata();
writedata();
}
Run Code Online (Sandbox Code Playgroud) 我正在阅读 Angular 的文档及其 RxJS 库的使用。我找到了这个信息
您可以使用管道将运算符连接在一起。管道允许您将多个函数组合成一个函数。pipeline() 函数将要组合的函数作为参数,并返回一个新函数,该函数在执行时会按顺序运行组合函数。
所以管道的目的是链接多个函数,但让我好奇的是,我多次看到pipe
内部只使用一个函数,例如:
this.itemSubscription = this.store
.pipe(select(state => state.items.root))
.subscribe(state => {
this.items = state.items;
});
Run Code Online (Sandbox Code Playgroud)
当我尝试使用select
withoutpipe
时,我的 tslint 会说:
select 已弃用:从 6.1.0 开始。请改用可管道选择运算符。(弃用)tslint(1)
为什么会发生这种情况?我错过了什么吗?在网上找不到相关解释。