我很好奇如何才能更有效地实例化Java中的字典。目前,我有可传递的代码,但是我以一种非常模糊的方式填充数据。
有什么办法可以像这样初始化字典吗?记录的是python:
westernCanadaAdjList = { 'BC': ['AB'],
'AB': ['BC', 'SK'],
'SK': ['AB', 'MB'],
'MB': ['SK']
}
Run Code Online (Sandbox Code Playgroud)
我发现出于演示目的,这一点要清晰得多。
我当前在Java中的代码:
public class Main {
public static void main(String[] args) {
//Adjacency List representation through a dictionary. Allows fast O(1) lookup time.
Map<String,ArrayList<String>> adjList = new HashMap<String,ArrayList<String>>();
//Adding values for Edmonton
adjList.put("Edmonton", new ArrayList<String>());
adjList.get("Edmonton").add("Neighbour1");
adjList.get("Edmonton").add("Neighbour2");
adjList.get("Edmonton").add("Neighbour3");
//Adding values for Vancouver
adjList.put("Vancouver", new ArrayList<String>());
adjList.get("Vancouver").add("V neighbour1");
adjList.get("Vancouver").add("V neighbour2");
System.out.println(adjList.keySet() +" And Values " + adjList.values());
for (String neighbour: adjList.get("Edmonton")){
System.out.println(neighbour);
}
for (String …Run Code Online (Sandbox Code Playgroud) 使用 React-Markdown,我可以充分使用我的自定义构建组件。但这是在降价中使用特定的预先构建的关键字。像段落或图像。效果非常好。但问题是,这些似乎都是预先构建的单词/条件,如段落、标题或图像。
我找不到在我的降价中添加新关键字的方法,例如要使用的“CustomComponent”。这就是我现在所需要的><
这对我来说很好用,可以将降价图像制作成我在其他地方制作的自定义“页脚”组件。我知道这很荒谬,但它确实有效。但我不知道如何让这个渲染器接受/创建一个新的关键字,如“emoji”或“customComponent”或“somethingSilly”。
let body =
``;
const renderers = {
image: () => <Footer/>
};
<ReactMarkdown source={body} renderers={renderers} />;
Run Code Online (Sandbox Code Playgroud)
一些文档: https://reposhub.com/react/miscellaneous/rexxars-react-markdown.html https://github.com/rexxars/commonmark-react-renderer/blob/master/src/commonmark-react-renderer。 js#L50
示例: https: //codesandbox.io/s/react-markdown-with-custom-renderers-961l3 ?from-embed=&file=/src/App.js
但没有任何内容表明我如何使用“CustomComponent”来指示注入自定义组件。
我正在尝试从我的数据库中检索一篇文章,该文章的格式类似于 Markdown 中的格式(基本上是一个巨大的字符串)。我正在使用 typescript 和 redux 进行常规反应——这是我的应用程序中唯一需要它的部分。
"
# Title
## Here is a subtitle
Some text
<CustomComponentIMade/>
Even more text after.
<CustomComponentIMade/>
"
Run Code Online (Sandbox Code Playgroud) 我只想更改下拉菜单背景颜色的颜色,但我尝试的任何操作都不起作用,我感到困惑。
我没什么可说的了,stackoverflow 希望我添加更多文本,但我只能说我一直在谷歌上搜索各种解决方案,但到目前为止没有任何效果。
const BootstrapInput = withStyles((theme: Theme) =>
createStyles({
root: {
'label + &': {
marginTop: theme.spacing(3),
},
},
selectMenu: {
color: 'rgba(1,1,255,1)',
backgroundColor: "#rgba(255,0,0,1)",
"& ul": {
backgroundColor: "#rgba(255,0,0,1)",
},
"& li": {
backgroundColor: "#rgba(255,0,0,1)",
fontSize: 12,
},
},
input: {
borderRadius: 0,
position: 'inherit',
backgroundColor: 'rgba(0,0,0,0)',
color: 'rgba(255,255,255,1)',
border: '1px solid rgba(255,255,255,0.2)',
fontSize: 15,
padding: '10px 26px 10px 12px',
transition: theme.transitions.create(['border-color', 'box-shadow']),
// Use the system font instead of the default Roboto font.
fontFamily: [
'-apple-system',
'BlinkMacSystemFont', …Run Code Online (Sandbox Code Playgroud)