欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue使用driver.js做引導(dǎo)頁

 更新時(shí)間:2022年02月10日 10:02:44   作者:織_網(wǎng)  
Driver.js是一個(gè)功能強(qiáng)大且高度可定制的基于原生JavaScript開發(fā)的新用戶引導(dǎo)庫,本文主要介紹了Vue使用driver.js做引導(dǎo)頁,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

輕量級(jí)、無依賴的原生 JavaScript 引擎,可將用戶的注意力集中在整個(gè)頁面上;這是一個(gè)功能強(qiáng)大且高度可定制的基于原生JavaScript開發(fā)的新用戶引導(dǎo)庫。

簡介及使用教程

Driver.js是一個(gè)功能強(qiáng)大且高度可定制的基于原生JavaScript開發(fā)的新用戶引導(dǎo)庫。它沒有依賴項(xiàng),支持所有主要瀏覽器。

特點(diǎn):

  • 簡單:簡單易用,完全沒有外部依賴
  • 高度可定制:有一個(gè)強(qiáng)大的api,可以用于你希望突出顯示任何內(nèi)容
  • 高亮顯示:頁面功能介紹上的任意元素(字面上的任意)
  • 功能介紹:為你的web應(yīng)用程序創(chuàng)建強(qiáng)大的功能介紹
  • 焦點(diǎn)移位器:為用戶友好添加焦點(diǎn)移位器
  • 用戶友好:通過鍵盤行為控制一切
  • 一致行為:所有瀏覽器(包括著名的IE)都可以使用
  • MIT聲明:免費(fèi)用于個(gè)人和商業(yè)用途。

安裝

Npm

npm i driver.js

Yarn

yarn add driver.js

瀏覽器

<script src="https://unpkg.com/driver.js/dist/driver.min.js"></script>
<link rel="stylesheet" >


<!-- 或者 -->
<link rel="stylesheet" href="/dist/driver.min.css">
<script src="/dist/driver.min.js"></script>

使用

引入

import Driver from 'driver.js';
import 'driver.js/dist/driver.min.css';

簡單示例

const driver = new Driver();
driver.highlight('#create-post');

image.png

交互時(shí)高亮元素

const focusDriver = new Driver();

// Highlight the section on focus
document.getElementById('creation-input')
  .addEventListener('focus', (e) => {
    focusDriver.focus('#creation-input');
  });

image.png

帶彈窗

const driver = new Driver();
driver.highlight({
  element: '#some-element',
  popover: {
    title: 'Title for the Popover',
    description: 'Description for it',
  }
});

image.png

彈窗支持定義位置、HTML內(nèi)容等

創(chuàng)建功能介紹

const driver = new Driver();
// Define the steps for introduction
driver.defineSteps([
  {
    element: '#first-element-introduction',
    popover: {
      className: 'first-step-popover-class',
      title: 'Title on Popover',
      description: 'Body of the popover',
      position: 'left'
    }
  },
  {
    element: '#second-element-introduction',
    popover: {
      title: 'Title on Popover',
      description: 'Body of the popover',
      position: 'top'
    }
  },
  {
    element: '#third-element-introduction',
    popover: {
      title: 'Title on Popover',
      description: 'Body of the popover',
      position: 'right'
    }
  },
]);
// Start the introduction
driver.start();

image.png

彈出框定位

您還可以將彈出框的位置更改為left, left-center, left-bottom, top, top-center, top-right, right, right-center,right-bottombottom, bottom-center, bottom-right, mid-center。

const driver = new Driver();
driver.highlight({
  element: '#some-element',
  popover: {
    title: 'Title for the Popover',
    description: 'Description for it',
    // position can be left, left-center, left-bottom, top,
    // top-center, top-right, right, right-center, right-bottom,
    // bottom, bottom-center, bottom-right, mid-center
    position: 'left',
  }
});

如果不指定位置或者指定為 be auto,它會(huì)自動(dòng)為popover找到合適的位置并顯示出來

在這里插入圖片描述

選項(xiàng)

Driver 選項(xiàng)

const driver = new Driver({
  className: 'scoped-class', //包裹driver.js彈窗的類名 className to wrap driver.js popover
  animate: true,  // 高亮元素改變時(shí)是否顯示動(dòng)畫 Animate while changing highlighted element
  opacity: 0.75,  //背景透明度(0 表示只有彈窗并且沒有遮罩) Background opacity (0 means only popovers and without overlay)
  padding: 10,   //  元素與邊緣的距離 Distance of element from around the edges
  allowClose: true, // 是否允許點(diǎn)擊遮罩時(shí)關(guān)閉 Whether clicking on overlay should close or not
  overlayClickNext: false, //是否允許點(diǎn)擊遮罩時(shí)移到到下一步 Should it move to next step on overlay click
  doneBtnText: 'Done', // 最終按鈕上的文本 Text on the final button
  closeBtnText: 'Close', // 當(dāng)前步驟關(guān)閉按鈕上的文本 Text on the close button for this step
  nextBtnText: 'Next', //當(dāng)前步驟下一步按鈕上的文本 Next button text for this step
  prevBtnText: 'Previous', // 當(dāng)前步驟上一步按鈕上的文本 Previous button text for this step
  showButtons: false, //是否在底部顯示控制按鈕 Do not show control buttons in footer
  keyboardControl: true, // 是否允許通告鍵盤控制(escape關(guān)閉,箭頭鍵用于移動(dòng))Allow controlling through keyboard (escape to close, arrow keys to move)
  scrollIntoViewOptions: {}, //  `scrollIntoView()` 方法的選項(xiàng) We use `scrollIntoView()` when possible, pass here the options for it if you want any
  onHighlightStarted: (Element) {}, // 元素開將要高亮?xí)r調(diào)用Called when element is about to be highlighted
  onHighlighted: (Element) {}, // 元素開完全高亮?xí)r調(diào)用Called when element is fully highlighted
  onDeselected: (Element) {}, // 取消選擇時(shí)調(diào)用 Called when element has been deselected
  onReset: (Element) {},        // 遮罩將要關(guān)閉時(shí)調(diào)用 Called when overlay is about to be cleared
  onNext: (Element) => {},      // 任何步驟中移到到下一步時(shí)調(diào)用Called when moving to next step on any step
  onPrevious: (Element) => {},  // 任何步驟中移到到上一步時(shí)調(diào)用Called when moving to next step on any step
});

step 選項(xiàng)

const stepDefinition = {
  element : '#some-item' ,         // 查詢要突出顯示的選擇器字符串或節(jié)點(diǎn)
  stageBackground : '#ffffff' ,    // 這將覆蓋驅(qū)動(dòng)程序中設(shè)置的
  popover : {                     // 不會(huì)有 popover如果為空或未給定
    className : 'popover-class' ,  // 除了驅(qū)動(dòng)程序選項(xiàng)中的一般 className 之外,還要包裝此特定步驟 popover 的 className
    title : 'Title' ,              // 彈出框上的標(biāo)題
    description : 'Description' , // 彈出框的主體
    showButtons : false ,          // 不要在頁腳中顯示控制按鈕
    doneBtnText : 'Done' ,         // 最后一個(gè)按鈕上的文本
    closeBtnText : 'Close' ,       // 關(guān)閉按鈕上的文本
    nextBtnText : 'Next' ,         // 下一個(gè)按鈕文本
    prevBtnText : 'Previous' ,     // 上一個(gè)按鈕文本
  } ,
  onNext : ( )  =>  { } ,              // 從當(dāng)前步驟移動(dòng)到下一步時(shí)調(diào)用
  onPrevious :( )  =>  { } ,          // 從當(dāng)前步驟移動(dòng)到上一步時(shí)調(diào)用
} ;

API方法

const driver = new Driver(driverOptions);

const isActivated = driver.isActivated; // 檢查driver是否激活Checks if the driver is active or not
driver.moveNext();     // 移動(dòng)到步驟列表中的下一步 Moves to next step in the steps list
driver.movePrevious(); // 移動(dòng)到步驟列表中的上一步 Moves to previous step in the steps list
driver.start(stepNumber = 0);  // 從指定的步驟開始 Starts driving through the defined steps
driver.highlight(string|stepDefinition); // 高亮通過查詢選擇器指定的或步驟定義的元素 highlights the element using query selector or the step definition
driver.reset(); // 重置遮罩并且清屏Resets the overlay and clears the screen
driver.hasHighlightedElement(); //檢查是否有高亮元素 Checks if there is any highlighted element
driver.hasNextStep(); // 檢查是否有可移動(dòng)到的下一步元素 Checks if there is next step to move to
driver.hasPreviousStep(); // 檢查是否有可移動(dòng)到的上一步元素。Checks if there is previous step to move to

driver.preventMove();// 阻止當(dāng)前移動(dòng)。如果要執(zhí)行某些異步任務(wù)并手動(dòng)移動(dòng)到下一步,則在“onNext”或“onPrevious”中很有用 Prevents the current move. Useful in `onNext` or `onPrevious` if you want to
// perform some asynchronous task and manually move to next step



const activeElement = driver.getHighlightedElement();// 獲取屏幕上當(dāng)前高亮元素 Gets the currently highlighted element on screen
const lastActiveElement = driver.getLastHighlightedElement();
activeElement.getCalculatedPosition(); // 獲取活動(dòng)元素的屏幕坐標(biāo)Gets screen co-ordinates of the active element
activeElement.hidePopover();  // 隱藏彈窗Hide the popover
activeElement.showPopover();  // 顯示彈窗Show the popover

activeElement.getNode();  // 獲取此元素后面的DOM元素Gets the DOM Element behind this element
你可以使用各種各樣的選項(xiàng)來實(shí)現(xiàn)你想要的一切。You can use a variety of options to achieve whatever you may want. 

引導(dǎo)頁效果

Driver.js -Demo 是一個(gè)指南性質(zhì)的庫
訪問GitHub

通用引導(dǎo)頁

新建主頁面文件
layout

<template>
  <div :class="classObj" class="app-wrapper">
    <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
    <sidebar class="sidebar-container" />
    <div :class="{hasTagsView:needTagsView}" class="main-container">
      <div :class="{'fixed-header':fixedHeader}">
        <navbar />
        <tags-view v-if="needTagsView" />
      </div>
      <app-main />
      <right-panel v-if="showSettings">
        <settings />
      </right-panel>
    </div>
  </div>
</template>

<script>
import RightPanel from '@/components/RightPanel'
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex'
import Driver from 'driver.js' // import driver.js
import 'driver.js/dist/driver.min.css' // import driver.js css
import steps from './steps'

export default {
  name: 'Layout',
  components: {
    AppMain,
    Navbar,
    RightPanel,
    Settings,
    Sidebar,
    TagsView
  },
  mixins: [ResizeMixin],
  data() {
    return {
      driver: null
    }
  },
  computed: {
    ...mapState({
      sidebar: state => state.app.sidebar,
      device: state => state.app.device,
      showSettings: state => state.settings.showSettings,
      needTagsView: state => state.settings.tagsView,
      fixedHeader: state => state.settings.fixedHeader
    }),
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === 'mobile'
      }
    }
  },
  mounted() {
    this.driver = new Driver({
      opacity: 0.1,
      animate: true,
      doneBtnText: '我知道了',
      closeBtnText: '跳過', //  關(guān)閉按鈕文案
      nextBtnText: '下一步', // 下一步的按鈕文案
      prevBtnText: '上一步', // 上一步的按鈕文案
      keyboardControl: true // 允許通過鍵盤控制(退出關(guān)閉,箭頭鍵移動(dòng))
    })
    console.log(this.driver)
    this.firstLogin()
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
    },
    // 用戶是否首次登錄
    firstLogin() {
      const firstDate = localStorage.getItem('firstDate')
      // 獲取當(dāng)前時(shí)間(年月日)
      const now = new Date().toLocaleDateString()
      // 轉(zhuǎn)換成時(shí)間戳
      const time = Date.parse(new Date(now))
      if (localStorage.getItem('firstDate')) {
        console.log('頁面被刷新')
        if (time > firstDate) {
          localStorage.setItem('firstDate', JSON.stringify(time))
        }
      } else {
        this.guide()
        localStorage.setItem('firstDate', JSON.stringify(time))
        console.log('首次被加載')
      }
    },
    // 頁面引導(dǎo)
    guide() {
      this.driver.defineSteps(steps)
      this.driver.start()
    }
  }
}
</script>

<style lang="scss" scoped>
  @import "~@/styles/mixin.scss";
  @import "~@/styles/variables.scss";

  .app-wrapper {
    @include clearfix;
    position: relative;
    height: 100%;
    width: 100%;

    &.mobile.openSidebar {
      position: fixed;
      top: 0;
    }
  }

  .drawer-bg {
    background: #000;
    opacity: 0.3;
    width: 100%;
    top: 0;
    height: 100%;
    position: absolute;
    z-index: 999;
  }

  .fixed-header {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 9;
    width: calc(100% - #{$sideBarWidth});
    transition: width 0.28s;
  }

  .hideSidebar .fixed-header {
    width: calc(100% - 54px)
  }

  .mobile .fixed-header {
    width: 100%;
  }
</style>

新建 steps.js 文件

// 定義介紹的步驟
const steps = [
  {
    element: '#hamburger-container',
    stageBackground: '#fff',
    popover: {
      title: '側(cè)邊欄按鈕',
      description: '打開或者關(guān)閉側(cè)邊欄',
      position: 'bottom'
    }
  },
  {
    element: '#sidebar-container',
    popover: {
      title: '側(cè)邊欄',
      description: '側(cè)邊欄及路由',
      position: 'right-center'
    }
  },
  {
    element: '#breadcrumb-container',
    popover: {
      title: '面包屑導(dǎo)航',
      description: '指示當(dāng)前頁的位置',
      position: 'bottom'
    }
  },
  {
    element: '#header-search',
    popover: {
      title: '頁面搜索',
      description: '頁面搜索,快速導(dǎo)航',
      position: 'left'
    }
  },
  {
    element: '#screenfull',
    popover: {
      title: '滿屏',
      description: '將頁面設(shè)置為全屏',
      position: 'left'
    }
  },
  {
    element: '#size-select',
    popover: {
      title: '開關(guān)的大小',
      description: '系統(tǒng)切換大小',
      position: 'left'
    }
  },
  {
    element: '#lang-select',
    popover: {
      title: '國際化',
      description: '中英文切換',
      position: 'left'
    },
    padding: 0
  },
  {
    element: '#personal_settings',
    popover: {
      title: '個(gè)人中心',
      description: '個(gè)人賬號(hào)設(shè)置及操作',
      position: 'left'
    },
    padding: 0
  },
  {
    element: '#tags-view-container',
    popover: {
      title: '標(biāo)簽視圖',
      description: '您訪問的頁面的歷史',
      position: 'bottom-center'
    },
    padding: 0
  },
  {
    element: '#theme_settings',
    popover: {
      title: '主題設(shè)置',
      description: '設(shè)置自己喜歡的主題',
      position: 'right-center'
    },
    padding: 0
  },
  {
    element: '#app_main',
    stageBackground: '#fff',
    popover: {
      className: 'app-container',
      title: '主體內(nèi)容區(qū)',
      // description: '主體內(nèi)容的一系列操作',
      position: 'top-center'
    },
    padding: -30
  }
]

export default steps

到此這篇關(guān)于Vue使用driver.js做引導(dǎo)頁的文章就介紹到這了,更多相關(guān)Vue driver.js引導(dǎo)頁內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue使用Vuex一步步封裝并使用store全過程

    Vue使用Vuex一步步封裝并使用store全過程

    這篇文章主要介紹了Vue使用Vuex一步步封裝并使用store全過程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • 淺談Vue響應(yīng)式(數(shù)組變異方法)

    淺談Vue響應(yīng)式(數(shù)組變異方法)

    這篇文章主要介紹了淺談Vue響應(yīng)式(數(shù)組變異方法),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-05-05
  • vue項(xiàng)目中監(jiān)聽手機(jī)物理返回鍵的實(shí)現(xiàn)

    vue項(xiàng)目中監(jiān)聽手機(jī)物理返回鍵的實(shí)現(xiàn)

    這篇文章主要介紹了vue項(xiàng)目中監(jiān)聽手機(jī)物理返回鍵的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • vue報(bào)錯(cuò)之exports is not defined問題的解決

    vue報(bào)錯(cuò)之exports is not defined問題的解決

    這篇文章主要介紹了vue報(bào)錯(cuò)之exports is not defined問題的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • treeSelect樹組件設(shè)置父節(jié)點(diǎn)禁用的方法實(shí)例

    treeSelect樹組件設(shè)置父節(jié)點(diǎn)禁用的方法實(shí)例

    這篇文章主要給大家介紹了關(guān)于treeSelect樹組件設(shè)置父節(jié)點(diǎn)禁用的相關(guān)資料,文中通過圖文以及示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-12-12
  • Vue中使用matomo進(jìn)行訪問流量統(tǒng)計(jì)的實(shí)現(xiàn)

    Vue中使用matomo進(jìn)行訪問流量統(tǒng)計(jì)的實(shí)現(xiàn)

    這篇文章主要介紹了Vue中使用matomo進(jìn)行訪問流量統(tǒng)計(jì)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Vue3.js自定義組件 v-model詳解

    Vue3.js自定義組件 v-model詳解

    在Vue3 中,v-model是用于創(chuàng)建雙向數(shù)據(jù)綁定的指令,通常,我們使用該指令將任何 HTML 表單元素與一個(gè)變量綁定以收集輸入值,本文給大家介紹Vue3.js自定義組件 v-model,感興趣的朋友一起看看吧
    2023-10-10
  • VUE前端實(shí)現(xiàn)防抖節(jié)流Lodash工具庫舉例詳解

    VUE前端實(shí)現(xiàn)防抖節(jié)流Lodash工具庫舉例詳解

    這篇文章主要介紹了Lodash庫和自定義防抖、節(jié)流函數(shù)的使用方法,包括它們的定義、應(yīng)用示例及應(yīng)用場(chǎng)景文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-01-01
  • Vue3基于?rem?比例縮放方案示例詳解

    Vue3基于?rem?比例縮放方案示例詳解

    這篇文章主要介紹了Vue3基于rem比例縮放方案,本縮放方案置于hooks中即可,文中通過示例代碼介紹了vue-cli3 中使用rem布局的方法,需要的朋友可以參考下
    2023-05-05
  • 詳解Vue組件之間通信的七種方式

    詳解Vue組件之間通信的七種方式

    這篇文章主要介紹了Vue組件之間通信的七種方式,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-04-04

最新評(píng)論