vue.js 弹出窗口_Vue.js的简单,轻巧和优雅的全局通知弹出窗口

vue.js 弹出窗口

VueUp (VueUp)

Simple, lightweight and elegant global notification popup for Vue.js.

Vue.js的简单,轻巧和优雅的全局通知弹出窗口。

安装 (Install)

npm install --save vueup

Somewhere in your app:

应用中的某个位置:

import Vue   from 'vue'
import VueUp from 'vueup'

Vue.use(VueUp)
Nuxt.js (Nuxt.js)

To use VueUp with Nuxt.js deploy the app with the --spa or --s flag to disable server-side rendering. For more information see nuxtjs.org/guide/commands/.

要将VueUp与Nuxt.js一起使用,请使用--spa--s标志部署应用程序以禁用服务器端呈现。 有关更多信息,请参阅nuxtjs.org/guide/commands/

Otherwise, you can do the following steps:

否则,您可以执行以下步骤:

File plugins/vueup.js:

文件plugins/vueup.js

import Vue from 'vue'
import VueUp from 'vueup'

Vue.use(VueUp)

Then, add the file inside the plugins key of nuxt.config.js:

然后,将文件添加到nuxt.config.js的plugins键中:

module.exports = {
  plugins: [
    { src: '~/plugins/vueup', ssr: false }
  ]
}

Note: The key ssr is used to disable the server-side rendering for VueUp because it's a client side library. For more information see nuxtjs.org/guide/plugins/.

注意:密钥ssr用于禁用VueUp的服务器端渲染,因为它是客户端库。 有关更多信息,请参阅nuxtjs.org/guide/plugins/

I would recommend to add the VueUp element <vue-up></vue-up> under the </nuxt> element in the layouts/default.vue file.

我建议在layouts/default.vue文件的</nuxt>元素下添加VueUp元素<vue-up></vue-up>

用法 (Usage)

Add the <vue-up> component to one point in your application:

<vue-up>组件添加到应用程序中的一点:

<template>
  <div>
    <vue-up></vue-up>
  </div>
</template>

To trigger the notification use the $popup method:

要触发通知,请使用$popup方法:

export default {
  ...
  methods: {
    notify () {
      this.$popup({ message: 'A message' })
    }
  }
}

API (API)

this.$popup(string | Object)

this.$popup('message')

// or

this.$popup({
    message         : 'message',
    color           : '#423452',
    backgroundColor : 'rgba(0, 0, 0, 0.4)',
    delay           : 4
})

翻译自: https://vuejsexamples.com/simple-lightweight-and-elegant-global-notification-popup-for-vue-js/

vue.js 弹出窗口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值