我无法从https://randomuser.me/api/获取我的api数据
但是,当我使用http://dummy.restapiexample.com/api/v1/employees等其他API时,它可以工作。
错误:
import React from "react";
import "./App.css";
import Start from "./start";
function App() {
return (
<div className="App">
<Start />
</div>
);
}
export default App;
Run Code Online (Sandbox Code Playgroud)
start.js
import React, { Component } from "react";
import Axios from "axios";
class Start extends Component {
constructor(props) {
super(props);
this.state = {
results: []
};
}
componentDidMount() {
Axios.get("https://randomuser.me/api/").then(res => {
const results = res.data;
this.setState({ results });
console.log(results);
});
}
render() {
return (
<div>
{this.state.results.map(result …Run Code Online (Sandbox Code Playgroud) 有没有解决方案如何检查字符串(例如:Google)并将链接反应路由器添加到特定单词(例如:Google)?
像这张照片的例子
前
后
这是我非常简单的代码
import React, { Component } from "react";
import { Link } from "react-router-dom";
class App extends Component {
state = {
text: "Google is my Friend, Google is Search Engine, Thanks to google"
website: "Google Friend"
};
render() {
let text = null;
if (this.state.text.includes(this.state.website)) {
return (text = (
<div>
<Link to={"/example"}>Google </Link> then state text
</div>
));
}
return <div>{text}</div>;
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
如果您可以向我展示如何在特定单词(例如:Google)内添加样式(例如更改颜色,或添加粗体/斜体或其他内容),那将会更有帮助
谢谢