Skip to main content
Version: 7.3.0

升级指南

🌐 Upgrade Guide

在升级到较新版本的 Turf 时,请查看 CHANGELOGrelease notes 以了解任何重大更改。如果升级后出现错误,请查看 API docs 中你的函数在各版本之间是否有更改,并根据需要进行迁移。

🌐 When upgrading to a newer version of Turf, see the CHANGELOG and release notes for any breaking changes. If you are getting errors after upgrade, look to see if the API docs have changed for your functions between versions and migrate them as appropriate.

你如何升级 Turf 将取决于你的具体环境和工具。以下是一些指导方针,帮助你入门。

🌐 How you upgrade Turf will depend on your specific environment and tooling. Here are some guidelines to get you started.

Turf 已发布版本的真实来源是 NPM。你也可以使用其他重新发布这些包的提供商。

🌐 The source of truth for published versions of Turf is NPM. You are welcome to use other providers that republish these packages.

在 Node.js 中

🌐 In Node.js

# If you use the all-inclusive turf library
npm update --save @turf/turf

# if you use the smaller individual turf packages
npm update --save @turf/helpers @turf/buffer

作为 v7 版本包含 CommonJS 和 ESM 软件包。

🌐 As of v7, both CommonJS and ESM bundles are included.

在浏览器中

🌐 In browser

无论是本地下载,还是直接包含第三方版本的 turf,都有多个 CDN 可供选择,每个 CDN 都有一个 URL 方案,允许你指定所需的版本,并提供一定的灵活性。根据你的需求适当构建你的 URL:

🌐 Whether downloading locally, or including a 3rd party version of turf directly, there are multiple CDN's to choose from and each has a URL scheme that allows you to specify what version you want, with some flexibility. Structure your URL as appropriate for your needs:

以下是从 Turf 6.x 迁移到 7.x 的示例。

🌐 Here's an example of migrating from Turf 6.x to 7.x

<script src="https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js"></script>

becomes

<script src="https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js"></script>

不建议在生产应用中使用始终提供 latest 最新版本的 Turf 的 CDN URL。Turf 的主要版本之间存在会破坏功能的更改,这可能会导致你的应用出现故障。

🌐 It is not recommended to use a CDN URL that always gives you the latest bleeding edge version of Turf, especially in a production app. There are breaking changes to turf functions between major versions that can leave your app in a broken state.