我正在使用 react-native 并且我获取了一个带数组的 GET 请求。现在我需要这个 fetch() 来完成获取那个数组,这样我就可以调用一个函数来处理这个数组并用它做一些事情。我如何等待它完成?
这是我的要求:
componentWillMount(){
console.log("will mount");
fetch('SOME_API', {
method: "GET",
headers: {
Accept: 'text/javascript',
'Content-Type': 'text/javascript',
}
}).then(response => response.json()).then(responseJson => {
this.setState(function (prevState, props) {
return {questions: responseJson, loading: false}
})
})
}Run Code Online (Sandbox Code Playgroud)
当这个 get 请求将 responseJson 置于状态时,我想调用我的函数来处理该数组。
如果您需要更多信息,请发表评论。
谢谢!
我有“更改图像”按钮,我希望用户使用胶卷来更改图像。
但是我得到警告,我没有使用相机胶卷的许可。
如何检查是否已授予许可?如果不是,我想寻求许可。
这是我现在的代码:
_pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
console.log(result);
if (!result.cancelled) {
this.setState({ image: result.uri });
}
};Run Code Online (Sandbox Code Playgroud)
这可能是一个很愚蠢的问题,但我在这里有点困惑...
如果您需要更多信息,请发表评论。
谢谢!
我的状态中有一个数组:
state = {
some_array: [1,1,1,3,6,3,6,23], // sorry for the syntax it's changed
}
Run Code Online (Sandbox Code Playgroud)
现在我想更改具有索引的数组中的值,假设为 4,在本例中为数字 6,或者如果我想更改索引 1,则为第二个数字或数组。
我知道这可能很简单,但我很困惑。
如果您需要更多信息,请发表评论。
谢谢!
我正在使用 discord.py 来制作我的不和谐机器人,当有人输入消息时,我想检查用户是否可以说 foo#3645,如果不是,则执行其他操作,然后执行其他操作
if(messageAuthor == "foo#3645):
# do something
else:
# do something else
Run Code Online (Sandbox Code Playgroud)
我试过这个:
if(ctx.message.author == "foo#3465"):
# do something
Run Code Online (Sandbox Code Playgroud)
但这由于某种原因不起作用......
如果您需要更多信息,请发表评论。
我正在为我的网站制作页脚,我正在使用 flexbox 进行布局。这是我页脚的 CSS:
.footer {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 5vh;
background-color: transparent;
color: white;
text-align: center;
}
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:
他们之间有很大的空间。我如何减少那个空间?
如果您需要更多信息,请发表评论。
谢谢!
javascript ×3
react-native ×3
arrays ×1
css ×1
discord.py ×1
expo ×1
fetch ×1
flexbox ×1
html ×1
permissions ×1
python ×1
response ×1