vue-vnode-helper
Helpers for Vue's createElement inspired by hyperscript-helpers.
Example
// component.jsconst article h1 p = helpers // Get element helpers you want to use props: 'message' { // Apply createElement to vue-vnode-helper // and you can use more terse syntax for the render. return } components: OtherComponent
API Reference
-
helpers: { [key: string]: (selector?: string, data?: VNodeData, children?: VNodeChildren): VNodeThunk }
Built-in helpers. All HTML5 elements and special elements of Vue.js are available. The helpers generates
VNodeThunk
that must be transformed byapply
function. -
tag(tag?: string | Component, selector?: string, data?: VNodeData, children?: VNodeChildren): VNodeThunk
A fallback helper that can be specified any element/component name or component options object/constructor.
-
apply(createElement: CreateElement, thunk: VNodeThunk): VNode
Transform
VNodeThunk
to actual VNode. -
createHelper(tag?: string | Component): (selector?: string, data?: VNodeData, children: VNodeChildren) => VNodeThunk
Create a new vnode helper.
// Some Vue componentconst MyComp =props: 'message'template: '<div>{{ message }}'// Create MyComp helperconst myComp =// Use MyComp helper in another component{return}
License
MIT