GithubHelp home page GithubHelp logo

owl-create-api's Introduction

owl-create-api

codecov build

一个能够让 Vue 组件通过 API 方式调用的插件

安装

$ npm install owl-create-api

使用

import Vue from 'vue'
import CreateAPI from 'owl-create-api'

import Dialog from './dialog'

Vue.use(CreateAPI)

Vue.createAPI(Dialog)
// .vue
this.$myDialog({
  $props: {
    content: 'Content',
    btns: [{
      text: 'OK'
    }]
  },
  $events: {
  }
}).show()

更多参数示例

import Vue from 'vue'
import CreateAPI from 'owl-create-api'

import Dialog from './dialog'

Vue.use(CreateAPI, {
  componentPrefix: 'my-'
})

Vue.createAPI(Dialog, ['callback'], true)
  • api 调用 $props $events 更新数据
const dialog = this.$dialog({
  $props: {
    content: 'content',
    btns: [{
      text: 'Yes'
    }, {
      text: 'Change',
      callback: () => {
        this.content = 'change content' 
        return false
      }
    }],
    $class: 'my-class'
  },
  $events: {
    callback: e => console.log('visible callback', e)
  }
}).show()
  • slot createElement
this.$dialog(null, (createElement) => {
  return [
    createElement('p', 'other content')
  ]
}).show()
  • object params
this.$dialog({
  content: 'I am content',
  onCallback: () => console.log('on-events callback')
}).show()
  • $create
import Dialog from './dialog'

Dialog.$create({
  $props: {
    content: 'content',
    btns: [{
      text: 'unChangeProps',
      callback: () => {
        // this.content = 'change content' invalid
        return false
      }
    }]
  },
  $events: {
    callback: e => console.log('visible callback', e)
  }
}).show()

关于

owl-create-api's People

Contributors

dengwb1991 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.