随笔 - 657,  文章 - 0,  评论 - 116,  阅读 - 153万

场景

若依前后端分离版手把手教你本地搭建环境并运行项目:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/108465662

在上面的基础上,实现页面引导/新手指引的效果如下

 

 

intro.js

https://introjs.com/docs/examples/basic/hello-world

Hello World示例

https://introjs.com/docs/examples/basic/hello-world

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

1、插件安装

npm install intro.js --save

 

 

2、在main.js中全局引入并挂载

// 引入页面引导
import intro from 'intro.js' // introjs库
import 'intro.js/introjs.css' // introjs默认css样式
// introjs还提供了多种主题,可以通过以下方式引入
import 'intro.js/themes/introjs-modern.css' // introjs主题
// 加到prototype中,直接通过vue实例就能调用intro了
Vue.prototype.$intro = intro

3、页面添加元素,并设置data-intro和data-step属性,这里设置引导为两个img

复制代码
<template>
  <div>
    <img
      data-intro="这是第一步"
      data-step="1"
      src="../../assets/images/car.png"
    />
    <br />
    <img
      data-intro="这是第二步"
      data-step="2"
      src="../../assets/images/car.png"
    />
  </div>
</template>
复制代码

4、页面mounted方法中设置Option属性使上一 步、下一步、完成为中文显示,然后调用start()启用

  mounted() {
    this.$intro()
      .setOption("nextLabel", " 下一步 ")
      .setOption("prevLabel", " 上一步 ")
      .setOption("doneLabel", " 完成 ")
      .start();
  },

5、其他选项属性参考官网

https://introjs.com/docs/intro/options

 

 

6、页面完整代码

复制代码
<template>
  <div>
    <img
      data-intro="这是第一步"
      data-step="1"
      src="../../assets/images/car.png"
    />
    <br />
    <img
      data-intro="这是第二步"
      data-step="2"
      src="../../assets/images/car.png"
    />
  </div>
</template>

<script>
export default {
  name: "intro",
  data() {
    return {};
  },
  mounted() {
    this.$intro()
      .setOption("nextLabel", " 下一步 ")
      .setOption("prevLabel", " 上一步 ")
      .setOption("doneLabel", " 完成 ")
      .start();
  },
  methods: {},
};
</script>

<style scoped lang="scss">

</style>
复制代码

 

posted on   霸道流氓  阅读(1985)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示