小编Luk*_*kas的帖子

Github页面返回自述文件而不是index.html。无法托管我的React项目

我在gh页上托管我的React项目时遇到问题。我在github上有我 的仓库----> GitHub仓库我的页面返回自述文件而不是indx.html(public / index.html)。---> 我的页面

我应如何使用我的React应用程序正确处理我的页面?

github github-pages

4
推荐指数
3
解决办法
4091
查看次数

发生 npm run deploy 错误后

在 npm run deploy 之后,我在 Github 上遇到了类似上面Repo 的错误

我正在尝试在 Github 上的 gh-pages 上部署我的 react-app (create-react-app)

'gh-pages' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world-4@0.1.0 deploy: `npm run build&&gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world-4@0.1.0 deploy script 'npm run build&&gh-page
s -d build'.
npm ERR! Make sure you have the latest …
Run Code Online (Sandbox Code Playgroud)

deployment node.js npm github-pages reactjs

3
推荐指数
2
解决办法
6630
查看次数

localstorage 中的更改未触发事件侦听器

我有 React 组件。最初我在 UseEffect 中设置了一些 localStorage。此外,我添加了事件侦听器。单击文本后,它会更改 localStorage 值,但事件侦听器没有触发,为什么?

import React, { useEffect } from "react";

export default function App() {

  useEffect(() => {
    window.localStorage.setItem("item 1", 'val 1');
    window.addEventListener('storage', () => {
      alert('localstorage changed!')
    })
  }, []);

  const getData = () => {
    localStorage.setItem("item", "val chamged");
  };

  return (
    <div className="App">
      <h1 onClick={getData}>Change localstorage value</h1>

    </div>
  );
}
Run Code Online (Sandbox Code Playgroud)

https://codesandbox.io/s/naughty-engelbart-90tkw

javascript local-storage reactjs

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

文本宽度随屏幕宽度而变化

我怎样才能达到这样的效果:当屏幕宽度改变时,字符串"Essem"会改变它们的宽度?
我有HTML:

<h1><span>Essem</span><br />bli.</h1>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

html css text

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