运行以下命令之一安装该软件包:
¥Run one of the following commands to install the package:
# Using npm
npm install driver.js
# Using pnpm
pnpm install driver.js
# Using yarn
yarn add driver.js
或者,你可以使用 CDN 并将脚本添加到你的 HTML 文件中:
¥Alternatively, you can use CDN and include the script in your HTML file:
<script src="https://cdn.jsdelivr.net/npm/driver.js@latest/dist/driver.js.iife.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/driver.js@latest/dist/driver.css"/>
¥Start Using
安装完成后,你可以将该包导入到你的项目中。以下示例展示了如何高亮元素:
¥Once installed, you can import the package in your project. The following example shows how to highlight an element:
import { driver } from "driver.js";
import "driver.js/dist/driver.css";
const driverObj = driver();
driverObj.highlight({
element: "#some-element",
popover: {
title: "Title",
description: "Description"
}
});
¥Note on CDN
如果你正在使用 CDN,则必须使用 window
对象中的包:
¥If you are using the CDN, you will have to use the package from the window
object:
const driver = window.driver.js.driver;
const driverObj = driver();
driverObj.highlight({
element: "#some-element",
popover: {
title: "Title",
description: "Description"
}
});
继续阅读 入门指南 指南,了解更多关于该软件包的信息。
¥Continue reading the Getting Started guide to learn more about the package.