【问题标题】:p5 js sketch works locally but not on githubp5 js草图在本地工作,但不在github上
【发布时间】:2017-03-16 05:00:24
【问题描述】:

我有几个 p5.js 草图,所有这些草图都在本地工作,但没有一个会显示在 GitHub 页面上。这是html:

<html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
<script language="javascript" type="text/javascript" src="sketch1.js"></script>
<style> body {padding: 0; margin: 0;} </style>
</head>
<body>

这里是javascript:

function setup() {
 createCanvas(500,500);
 background(250, 212, 210);
 strokeWeight(4);
}

function draw() {
 line(mouseX, mouseY, pmouseX, pmouseY);
 if (mouseIsPressed == true) {
  stroke(250, 3, 80);
 } else {
  stroke(110, 164, 249);
} 

 }

【问题讨论】:

  • 能否提供github页面的链接?此外,您需要熟悉the developer tools。很有可能你的错误就在那里。
  • 我现在将查看开发人员工具。 here 是 GitHub 页面
  • 您刚刚链接到的 GitHub 页面不包含任何可运行的 p5.js 代码,您也没有将其添加到您的页面中。

标签: github p5.js


【解决方案1】:

如果您从 GitHub 存储库访问 .html 文件,它实际上不会显示呈现的 html 页面本身,而只会显示源代码。如果您想在 GitHub 上预览 html 文件,this answer 和 this answer 解决该问题。

【讨论】:

    【解决方案2】:

    我想你可能只是忘记向存储库添加目录(或者可能忘记将更改推送到 github)。我在您的存储库中看到 6 个文件,其中包括 p5.js:110-click.html、116.html、114.html、index copy.html、127-click.html 和 129-click.html。所有这些都包括libraries/p5.js,但您的存储库中没有libraries 目录。

    我猜你需要使用来自 repo 根目录的git add libraries 来添加这个目录(然后提交并推送到 github)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      相关资源
      最近更新 更多