小编Nes*_*ony的帖子

带有 nextjs 的 Material-ui 选项卡?

我有一个 Material-ui、nextjs 和 typescript 项目。我正在尝试让我的导航栏与 nextjs 一起使用:

import * as React from 'react';
import AppBar from '@material-ui/core/AppBar';
import Link from "next/link";
import {Tab, Tabs} from "@material-ui/core";

export default function NavBar() {
  return (
        <AppBar position="static">
          <Tabs>
              <Tab label="Timer"><Link href="timer" /> </Tab>
              <Tab label="Home" to="/" component={Link}  />
          </Tabs>
        </AppBar>
  );
}
Run Code Online (Sandbox Code Playgroud)

但这会导致构建失败。我有什么遗漏的吗?

javascript reactjs material-ui next.js

14
推荐指数
1
解决办法
8478
查看次数

使用 ZSH 时 IntelliJ 没有获取环境变量?

我的终端使用 oh-my-zsh。我已将 IntelliJ 设置/bin/zsh为 shell 路径。然而,我的文件中似乎没有环境变量.zshrc被拾取。我正在定义这样的环境变量(例如):

export GOOGLE_APPLICATION_CREDENTIALS="$HOME/mailcreds.json"
Run Code Online (Sandbox Code Playgroud)

但如果我跑:

echo $GOOGLE_APPLICATION_CREDENTIALS
Run Code Online (Sandbox Code Playgroud)

什么也没有出现。

terminal zsh intellij-idea oh-my-zsh

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

从docker启动npm吗?

嗨,我正在用npm运行一个基本的react项目,我正在尝试在docker容器中启动它。但是我实际上无法使项目运行。我的dockerfile看起来像这样:

FROM node:7.8.0


WORKDIR /

ADD . /


EXPOSE 80


RUN npm install

ENTRYPOINT npm run start
Run Code Online (Sandbox Code Playgroud)

我收到一条相关消息,说现在可以查看该项目,但是在浏览器中什么都没有显示。任何帮助,将不胜感激。

node.js npm docker

5
推荐指数
1
解决办法
5123
查看次数

当道具改变时重新渲染 React 组件?

我有一个带有 Mobx 商店的 React 组件,如下所示:

class Board extends Component {
  componentDidMount() {
    this.props.dataStore.getSinglePlayer(1)
    this.props.squareStore.getAllSquares()
  }

  componentWillReceiveProps(nextProps) {
    if (
      this.props.dataStore.currentPlayer !==
      this.nextProps.dataStore.currentPlayer
    ) {
      this.nextProps.dataStore.getSinglePlayer(1)
    }
  }

  randomNumber() {
    return Math.floor(Math.random() * 6) + 1
  }

  roll(playerId, playerPosition) {
    let dice1 = this.randomNumber()
    let dice2 = this.randomNumber()

    let totalRoll = dice1 + dice2
    let totalPosition = totalRoll + playerPosition
    this.props.dataStore.changeUserPosition(playerId, totalRoll)
    document.getElementById('dice').innerHTML =
      'You rolled ' + totalRoll + '!  You are now on ' + totalPosition
  }

  render() { …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs mobx

3
推荐指数
1
解决办法
1万
查看次数