我正在使用create-react-app从/ build文件夹中提供文件。通常,Github Pages会在根级别查看index.html,但我想指导它查看/ build以进行部署。
我已尝试在我的package.json配置中添加"homepage": "/build"
,而Github Settings表示已通过<username>.github.io
部署了func nextGame() {
UIView.animate(withDuration: 3, delay: 0.0, options: .allowAnimatedContent, animations: {
NSLog("Animation started")
self.labelWinningPlayer.center = CGPoint(x: self.labelWinningPlayer.center.x + 500, y: self.labelWinningPlayer.center.y)
self.buttonNextGameLabel.center = CGPoint(x: self.buttonNextGameLabel.center.x + 500, y: self.buttonNextGameLabel.center.y)
}, completion: { (finished: Bool) in
NSLog("Animation stopped")
self.labelWinningPlayer.isHidden = true
self.buttonNextGameLabel.isHidden = true
})
//sets buttons to start position
labelWinningPlayer.center = CGPoint(x: labelWinningPlayer.center.x - 1000, y: labelWinningPlayer.center.y)
buttonNextGameLabel.center = CGPoint(x: buttonNextGameLabel.center.x - 1000, y: buttonNextGameLabel.center.y)
//hides buttons that lay under the animated buttons
for i in 1...9 {
if let button = view.viewWithTag(i) as? UIButton {
button.setImage(nil, for: .normal)
}
}
activeGame = true
}
//animation should get started with this button
@IBAction func buttenNextGameAction(_ sender: Any) {
nextGame()
}
//slides buttons in
func slideNextGameButtons() {
labelWinningPlayer.isHidden = false
buttonNextGameLabel.isHidden = false
UIView.animate(withDuration: 0.5, animations: {
self.labelWinningPlayer.center = CGPoint(x: self.labelWinningPlayer.center.x + 500, y: self.labelWinningPlayer.center.y)
self.buttonNextGameLabel.center = CGPoint(x: self.buttonNextGameLabel.center.x + 500, y: self.buttonNextGameLabel.center.y)
})
}
。但是,该站点只显示我的README.md文件。
感谢任何帮助:)
答案 0 :(得分:0)
这里的问题是这是一个Web浏览器问题,而不是主机问题。当您访问网页时,您的浏览器始终会在网址上查找index.html
文件,以便localhost:8080
成为localhost:8080/index.html
。
这意味着有几种方法可以解决这个问题。您可以在根目录中创建一个index.html
文件,然后将其提供给构建文件夹中的脚本,如<script src="build/main.js"></script>
您还可能会遇到手动将/build
添加到网址末尾的痛苦和痛苦。但是你不希望用户必须这样做,所以你可以写一个脚本来重定向你。