小编okl*_*las的帖子

create-react-app在src目录之外导入限制

我正在使用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" />

我已经阅读了很多东西,说你可以对路径进行导入,但这对我来说仍然不起作用.任何帮助将不胜感激.我知道有很多这样的问题,但他们都告诉我要导入徽标或图像,所以我在大局中遗漏了一些东西.

javascript reactjs webpack create-react-app

93
推荐指数
14
解决办法
10万
查看次数

React Js:防止换行或在文本区域输入时提交

代码:

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)

reactjs

2
推荐指数
1
解决办法
1051
查看次数

Ruby错误 - 参数数量错误

我正在学习来自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)

ruby

0
推荐指数
1
解决办法
1180
查看次数

标签 统计

reactjs ×2

create-react-app ×1

javascript ×1

ruby ×1

webpack ×1