我正在使用create-react-app.我试图从我的公共文件夹中调用图像src/components.我收到此错误消息.
./src/components/website_index.js找不到模块:您试图导入位于项目src /目录之外的../../public/images/logo/WC-BlackonWhite.jpg.不支持src /之外的相对导入.你可以在src /中移动它,或者从项目的node_modules /中添加一个符号链接.
import logo from '../../public/images/logo_2016.png';
<img className="Header-logo" src={logo} alt="Logo" />
我已经阅读了很多东西,说你可以对路径进行导入,但这对我来说仍然不起作用.任何帮助将不胜感激.我知道有很多这样的问题,但他们都告诉我要导入徽标或图像,所以我在大局中遗漏了一些东西.
代码:
const Chat = props => {
const dispatch = useDispatch();
const messages = useSelector(state => state.Chat);
const [text, setText] = React.useState('');
return (
<Styled.ChatBox>
<Styled.ChatHeader>
<p>Chat Bot</p>
<div>
<FontAwesomeIcon icon={faAngleDown} size="1x" color="white" />
<FontAwesomeIcon icon={faTimes} size="1x" color="white" />
</div>
</Styled.ChatHeader>
<Styled.ChatLog>
{/* <Styled.MessageWrapper bot={true}>
<Styled.BotImg src={BotLogo} bot={true} />
<Styled.ChatMessage bot={true}>
dsasasasasasasasasasa
</Styled.ChatMessage>
</Styled.MessageWrapper> */}
{messages.map(message => (
<Styled.MessageWrapper bot={true}>
<Styled.BotImg src={BotLogo} bot={false} />
<Styled.ChatMessage bot={true}>{message.text}</Styled.ChatMessage>
</Styled.MessageWrapper>
))}
</Styled.ChatLog>
<Styled.ChatInput>
<textarea
value={text}
onChange={e => setText(e.target.value)}
placeholder="Digite aqui sua mensagem"
/> …Run Code Online (Sandbox Code Playgroud) 我正在学习来自java的ruby dev,我不明白为什么我会得到以下错误.@test是一个类变量,所以我应该能够输出它?
C:/Projects/RubyPlayground/Tester.rb:6:in `test': wrong number of arguments (ArgumentError)
from C:/Projects/RubyPlayground/Tester.rb:6:in `testMethod'
from C:/Projects/RubyPlayground/Tester.rb:10
Run Code Online (Sandbox Code Playgroud)
资源:
class Tester
@test = "here"
def testMethod()
puts test
end
s = Tester.new()
s.testMethod()
end
Run Code Online (Sandbox Code Playgroud)