vue.js 自定义组件_轻巧且可自定义的游览插件,可与Vue.js一起使用

vue.js 自定义组件

巡回赛 (Vue Tour)

Vue Tour is a lightweight, simple and customizable tour plugin for use with Vue.js. It provides a quick and easy way to guide your users through your application.

Vue Tour是一款轻巧,简单且可自定义的Tour插件,可与Vue.js一起使用。 它提供了一种快速简便的方法来指导您的用户浏览您的应用程序。

Vue-Tour

入门 (Getting Started)

You can install vue-tour using npm or by downloading the minified build on GitHub.

您可以使用npm或通过在GitHub上下载缩小版本来安装vue-tour

npm install vue-tour

Then import the plugin in your application entry point (typically main.js if you used vue-cli to scaffold your project) and tell Vue to use it. Also don't forget to include the styles. You can add the styles provided by default or customize them to your own liking.

然后将插件导入您的应用程序入口点(如果您使用vue-cli来搭建项目,则通常为main.js),并告诉Vue使用它。 另外,别忘了包括样式。 您可以添加默认提供的样式,也可以根据自己的喜好自定义样式。

import Vue from 'vue'
import App from './App.vue'
import VueTour from 'vue-tour'

require('vue-tour/dist/vue-tour.css')

Vue.use(VueTour)

new Vue({
  render: h => h(App)
}).$mount('#app')

Finally put a v-tour component in your template anywhere in your app (usually in App.vue) and pass it an array of steps. The target property of each step can target a DOM element in any component of your app (as long as it exists in the DOM when the concerned step pops up).

最后,将v-tour组件放在应用程序中任何位置的模板中(通常在App.vue中),并将其传递给一系列步骤。 每个步骤的target属性都可以在应用程序的任何组件中定位DOM元素(只要弹出相关步骤时该元素存在于DOM中)。

<template>
  <div>
    <div id="v-step-0">A DOM element on your page. The first step will pop on this element because its ID is 'v-step-0'.</div>
    <div class="v-step-1">A DOM element on your page. The second step will pop on this element because its ID is 'v-step-1'.</div>
    <div data-v-step="2">A DOM element on your page. The third and final step will pop on this element because its ID is 'v-step-2'.</div>

    <v-tour name="myTour" :steps="steps"></v-tour>
  </div>
</template>

<script>
  export default {
    name: 'my-tour',
    data () {
      return {
        steps: [
          {
            target: '#v-step-0',  // We're using document.querySelector() under the hood
            content: `Discover <strong>Vue Tour</strong>!`
          },
          {
            target: '.v-step-1',
            content: 'An awesome plugin made with Vue.js!'
          },
          {
            target: '[data-v-step="2"]',
            content: 'Try it, you\'ll love it!<br>You can put HTML in the steps and completely customize the DOM to suit your needs.',
            params: {
              placement: 'top'
            }
          }
        ]
      }
    },
    mounted: function () {
      this.$tours['myTour'].start()
    }
  }
</script>

For all individual elements you want to add a step on, make sure it can be retrieved with document.querySelector(). You can use any selector, an ID, a CSS class, data attributes, etc. Once this is done and your steps correctly target some DOM elements of your application, you can start the tour by calling the following method.

对于要添加步骤的所有单个元素,请确保可以使用document.querySelector()对其进行检索。 您可以使用任何选择器,ID,CSS类,数据属性等。完成此操作并且您的步骤正确定位了应用程序的某些DOM元素后,您可以通过调用以下方法开始漫游。

this.$tours['myTour'].start()

翻译自: https://vuejsexamples.com/a-lightweight-and-customizable-tour-plugin-for-use-with-vue-js/

vue.js 自定义组件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值