slim_Vuejs的Slim对话框

slim

超薄对话 (v-slim-dialog)

Slim Dialog for Vuejs.

Vuejs的Slim对话框。

安装 (Installation)

yarn add v-slim-dialog
# Or using npm
npm install v-slim-dialog

用法 (Usage)

import Vue from 'vue'

import 'v-slim-dialog/dist/v-slim-dialog.css'
import SlimDialog from 'v-slim-dialog'

Vue.use(SlimDialog)

选项参数 (Options params)

NameTypeRequiredDefault valueInfo
titleStringNoTitle of modal
okLabelStringNoOKLabel of button OK
cancelLabelStringNoCancelLabel of button cancel
sizeString('sm'or'lg')NoSize of modal
promptObjectNoHash for prompt {value: '', component: VueComponent}
名称 类型 需要 默认值 信息
标题 没有 模态标题
okLabel 没有 按钮标签确定
cancelLabel 没有 取消 按钮标签取消
尺寸 字符串('sm'或'lg') 没有 模态尺寸
提示 目的 没有 提示{value:``,component:VueComponent}的哈希值

在你的组件中 (In your component)

警报 (alert)

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, okLabel = 'OK', size }
   */
  showAlert() {
    const options = {title: 'Info', size: 'sm'}
    this.$dialogs.alert('Your message', options)
    .then(res => {
      console.log(res) // {ok: true|false|undefined}
    })
  }
}
//...

alert-1

确认 (confirm)

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, cancelLabel = 'Cancel', okLabel = 'OK', size }
   */
  showConfirm() {
    const options = {title: 'Confirm?', cancelLabel: 'No'}
    this.$dialogs.confirm('Your message!', options)
    .then(res => {
      console.log(res) // {ok: true|false|undefined}
    })
  }

}
//...

confirm

提示 (prompt)

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, okLabel = 'OK', size, prompt }
   */
  showPrompt() {
    const options = {title: 'Continue?', okLabel: 'Continue'}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

    // with custom input prompt
    const options = {title: 'Continue?', prompt: {component: 'cpf-cnpj'}}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

    // or
    import YourComponent from './YourComponent'
    const options = {title: 'Continue?', prompt: {component: YourComponent}}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

  }

}
//...

prompt

示例自定义提示组件 (Sample custom prompt Component)

This is the default component if you do not report

如果您不报告,则这是默认组件

<template>
  <input v-model='model'>
</template>

<script>
export default {
  props: {
    value: [Number, String]
  },

  computed: {
    model: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      }
    }
  },
  mounted() {
    this.$el.focus()
  }
}
</script>

发展历程 (Development)

# install dependencies
yarn install

# build with minification
yarn release

# publish
bin/publish

翻译自: https://vuejsexamples.com/slim-dialog-for-vuejs/

slim

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值