我正在使用反应导航器创建屏幕,但当屏幕打开时我无法更改标题栏的选项
我的代码(App.js):
function App() {
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{
headerTitleAlign: 'center',
headerTitle: props => <LogoTitle {...props} />,
headerRight: props => <HeaderRight {...props} />,
headerStyle: {
backgroundColor: '#F46A0D'
},
headerTintColor: '#fff',
}}>
<Stack.Screen name="Search" component={SearchScreen}/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
Run Code Online (Sandbox Code Playgroud)
我的 SearchScreen.js:
import React from 'react'
import { Text, View } from 'react-native'
import { Button } from 'react-native-paper'
const SearchScreen = ({ navigation }) => {
navigation.setOptions = {
headerTitle: props => <TextInput {...props} placeholder="Search" placeholderTextColor="#FFFF" style={{ …
Run Code Online (Sandbox Code Playgroud) 我想插入一个字符串的中间,但我不能使用String.Format
,因为该字符串包含{}
大括号.
这是我到目前为止所尝试的:
string code = "(function(){var myvariable = $"{variableToBeInterpolated}"});"
Run Code Online (Sandbox Code Playgroud)
返回:)预期; 预期
编辑:我尝试了下面的代码片段,插值现在正在工作,但代码不会在浏览器中执行.
"(function(){var myvariable=" + $"{myvariable c#}" + ")});"
Run Code Online (Sandbox Code Playgroud) 我试图为数组中的所有水果设置随机数,并返回一个包含减速器中具有异步函数的所有水果的对象,但只返回数组的最后一个元素
(async () =>
console.log(
await [("apple", "banana", "orange")].reduce(async (o, fruit) => {
const random_number = await new Promise((resolve) => setTimeout(() => resolve(Math.random()), 200));
return { ...o, [fruit]: random_number };
}, {})
))();
Run Code Online (Sandbox Code Playgroud)