Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chenfengyuan/create-vue-component

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chenfengyuan/create-vue-component

Convert anything to a Vue component.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
321
decreased by-24.82%
Maintainers
1
Weekly downloads
 
Created
Source

create-vue-component

Build Status Downloads Version

Convert anything to a Vue component.

Main

dist/
├── create-vue-component.js        (UMD)
├── create-vue-component.min.js    (UMD, compressed)
├── create-vue-component.common.js (CommonJS, default)
└── create-vue-component.esm.js    (ES Module)

Installation

npm install @chenfengyuan/create-vue-component

Usage

Syntax

createVueComponent(content, options)
  • content

    • Type: *
    • The content for creating Vue component.
  • options (optional)

    • Type: Object
    • The options for creating Vue component.
    • Properties:
      • tag
        • Type: String
        • Default: 'span'
        • The tag for root element of the created Vue component.
      • data
        • Type: *
        • The data as the second parameter if the content is a render function.
  • (return value)

    • Type: Object
    • The created Vue component.
    • If the given content is a valid Vue component then return a clone of the content.
    • If the given content is a function then return a Vue component with the content as the render property value.
    • If the given content is anything else then return a Vue component with the content as the template property value.

Examples

import createVueComponent from '@chenfengyuan/create-vue-component';

createVueComponent({
  template: '<p>Hello, World!</p>',
});
// will render as: <p>Hello, World!</p>

createVueComponent('<strong>Hello, World!</strong>');
// will render as: <span><strong>Hello, World!</strong></span>

createVueComponent('Hello, World!');
// will render as: <span>Hello, World!</span>

createVueComponent('Hello, World!', {
  tag: 'p',
});
// will render as: <p>Hello, World!</p>

createVueComponent(true);
// will render as: <span>true</span>

createVueComponent(1);
// will render as: <span>1</span>

createVueComponent(['Hello', 'World']);
// will render as: <span>Hello,World</span>

createVueComponent(function content(createElement, data, context) {
  return createElement('p', `Hello, ${data.name}!`);
}, {
  data: {
    name: 'World',
  },
});
// will render as: <p>Hello, World!</p>

createVueComponent({});
// will render as: <span>[object Object]</span>

createVueComponent();
// will render as: <span>undefined</span>

Browser support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Opera (latest)
  • Edge (latest)
  • Internet Explorer 9+

License

MIT © Chen Fengyuan

Keywords

FAQs

Package last updated on 28 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc