我使用axios进行了API调用。超时设置为2500毫秒。我所不希望的是axios在超时后返回一个值,因此我可以通知用户由于某些服务器或网络错误而中止该请求。
我如何初始化超时
const instance = axios.create();
instance.defaults.timeout = 2500;
Run Code Online (Sandbox Code Playgroud)
以下是超时后应返回值的函数
_post(url, body, token) {
return new Promise((resolve, reject) => {
instance
.post(url, body, {headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}})
.then(data => {
resolve(data);
})
.catch(error => {
reject(error);
});
});
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我使用了 react-slick 并使用 Slider 组件制作了一个旋转木马。代码如下,
const carousel = (props) => {
return (
<div style={{ height: '50%', marginTop: '20px' }}>
<Slider {...settings}>
<div className={text__bar}>
<div >
<font>Lorum Ipsum 1</font>
</div>
<div className={slide1} />
</div>
<div className={text__bar}>
<div>
<font>Lorum Ipsum 2</font>
</div>
<div className={slide1} />
</div>
<div className={text__bar}>
<div>
<font>Lorum Ipsum 3</font>
</div>
<div className={slide1} />
</div>
</Slider>
<div className={purple__bar}></div>
</div>
);
};
Run Code Online (Sandbox Code Playgroud)
和设置对象,
const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: …Run Code Online (Sandbox Code Playgroud) 这些是表格 1 的代码-->
namespace Passing_Values
{
public partial class Form1 : Form
{
string a="preset value";
public Form1()
{
InitializeComponent();
}
private void btnOpenF2_Click(object sender, EventArgs e)
{
new Form2().Show();
}
public void set(string p)
{
MessageBox.Show("This is Entered text in Form 2 " + p);
a = p;
MessageBox.Show("a=p done! and P is: " + p + "---and a is: " + a);
textBox1.Text = "Test 1";
textBox2.Text = a;
textBox3.Text = p;
}
private void …Run Code Online (Sandbox Code Playgroud) javascript ×2
axios ×1
c# ×1
css ×1
ecmascript-6 ×1
es6-promise ×1
react-slick ×1
reactjs ×1
slick.js ×1
typescript ×1
winforms ×1