# 新手引导
URL: /%E6%96%87%E6%A1%A3/04.%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/01.%20%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/01.%20%E5%9F%BA%E7%A1%80%E8%A7%84%E8%8C%83/18.%20%E5%89%8D%E7%AB%AF%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/%E6%96%B0%E6%89%8B%E5%BC%95%E5%AF%BC


# 新手引导

> TODO: 封装成通用方法

具体案例可参考 `src\views\wxwork\member\WxworkBatchTagList.vue`

## 导入

``` js
import intro from 'intro.js';
import 'intro.js/minified/introjs.min.css';
```

## 使用

在需要引导的元素上增加 ID（如果有 Class 就直接用 Class 也行）

``` js
  // 页面引导
  function handleStart() {
        intro()
          .setOptions({
            prevLabel:'上一步',
            nextLabel: '下一步',
            doneLabel: '完成',
            steps: [
              {
                title: '使用引导',
                intro: '本功能用于批量导入用户名单，并打上标签。',
              },
              {
                title: '下载导入模板',
                element: document.querySelector('#step1'),
                intro: '按照要求填写表单',
              }
            ],
          })
          .start();
      }
```

## 页头增加按钮

``` js
<PageWrapper title="批量打标签" contentBackground dense>
  <template #tags>
    <Icon icon="ant-design:alert-outlined" @click="handleStart" class="intro"></Icon>
  </template>
</PageWrapper>
```

``` less
<style scoped lang="less">
  .intro {
    color: @primary-color;
  }
</style>

```

## 全局元素获取

``` js
  import { useDesign } from '/@/hooks/web/useDesign';
  const { prefixVar } = useDesign('');
```

在 element 中，使用以下方法获取元素

``` js
{
  title: '下载导入模板',
  element: document.querySelector(`.${prefixVar}-layout-header-trigger`)!,
  intro: '按照要求填写表单',
}
```
