更改版本后获取JS错误:未定义XYZ

发布于 2025-01-22 15:36:29 字数 1292 浏览 1 评论 0原文

我正在使用React-Vis库。他们的读书文件说:

如果您在非节点环境中工作,也可以使用基本的HTML标签直接包含捆绑包和编译样式。

 < link rel =“ stylesheet” href =“ https://unpkg.com/react-vis/dist/style.css”>
< script type =“ text/javascript” src =“ https://unpkg.com/react-vis/dist/dist/dist.min.js”></script>
 

全局reactvis对象现在可以供您玩。

当我做到这一点时,它可以正常工作,并且我能够在代码中使用reactvis对象。它链接版本 1.11.7来自> umpkg。我想尝试版本1.11.5。因此,我尝试了以下内容:

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/browse/[email protected]/dist/dist.min.js"></script>

但是,现在它给了我以下错误:

Uncaught ReferenceError: reactVis is not defined

某种程度上,它无法引用reactvis代码。为什么这样?

I was using react-vis library. Their readme file says following:

If you're working in a non-node environment, you can also directly include the bundle and compiled style using basic html tags.

<link rel="stylesheet" href="https://unpkg.com/react-vis/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/react-vis/dist/dist.min.js"></script>

The global reactVis object will now be available for you to play around.

When I do exactly that, it works and I was able to use reactVis object in my code. It links versions 1.11.7 from unpkg. I wanted to try out version 1.11.5. So, I tried following:

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/browse/[email protected]/dist/dist.min.js"></script>

But, now it gives me following error:

Uncaught ReferenceError: reactVis is not defined

Somehow, it is not able to get reference to reactVis code. Why is this so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑,眼淚并存 2025-01-29 15:36:29

您使用的链接包含https://unpkg.com/browse/... /browse链接到该文件的HTML预览页。

链接到文件的原始版本remove /browse在您的情况下https://unpkg.com/ [email&nbsp; procented] /dist/dist/dist.min.js,链接到文件原始的文件。

例如。

console.log(
  reactVis
)
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/dist.min.js"></script>

The link you used contains https://unpkg.com/browse/... /browse links to the html preview page of the file.

To link to the raw version of the file remove /browse in your case to https://unpkg.com/[email protected]/dist/dist.min.js, which would link to the file raw.

eg.

console.log(
  reactVis
)
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/dist.min.js"></script>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文