Uncaught (in promise) ReferenceError: topojson is not defined

Uncaught (in promise) ReferenceError: topojson is not defined

我是 d3 的新人。我无法渲染美国地图,你能看看吗?

https://codepen.io/DeanWinchester88/pen/BaZYewv

d3.json(COUNTIES)
  .then( data =>  {
   let  states = topojson.feature(data, data.objects.states);
 

TopoJSON 从来不是任何 D3 包的一部分。因此,您必须引用它,例如:

<script src="https://unpkg.com/topojson@3"></script>

在 CodePen 中,“添加包”将创建:

import * as topojson from "https://cdn.skypack.dev/topojson@3.0.2"; 

(现在您将遇到全新的错误...)