@uni-component/vue
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

@uni-component/vue npm build status coverage

Unified component for Vue 3.

Installation

pnpm add @uni-component/core @uni-component/vue
# or with yarn
yarn add @uni-component/core @uni-component/vue
# or with npm
npm install @uni-component/core @uni-component/vue

Usage

UniComponent to React component:

import { uni2Vue } from '@uni-component/vue'

export const VueButton = uni2Vue(UniButton, (props, state, { renders }) => {
  const {
    n,
    rootClass,
    clickAction
  } = state
  const t = props.text ? props.text : renders.defaultRender && renders.defaultRender()
  return (
    <button className={rootClass} type={props.type} onClick={() => clickAction()}>
      <span>
        <>
          {t}
          {` ${n}`}
        </>
      </span>
      {props.appendRender?.()}
    </button>
  )
})

Entry:

/// <reference types="@uni-component/vue/platform" />
import { h, Fragment } from '@uni-component/core'
import '@uni-component/vue'
import { createApp } from 'vue'

const App = () => {
  return (
    <>
      <VueButton>child</VueButton>
      <VueButton primary={true} text='text'></VueButton>
    </>
  )
}

createApp(App).mount('#root')

JSX with tsconfig: { "jsxFactory": "h", "jsxFragmentFactory": "Fragment" }

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.9.00latest

Version History

VersionDownloads (Last 7 Days)Published
0.9.00
0.8.00
0.7.00
0.6.40
0.6.30
0.6.20
0.6.10
0.6.00
0.5.10
0.5.00
0.4.30
0.4.20
0.4.10
0.4.00
0.3.01
0.2.00
0.1.10
0.0.10

Package Sidebar

Install

npm i @uni-component/vue

Weekly Downloads

1

Version

0.9.0

License

MIT

Unpacked Size

27.7 kB

Total Files

12

Last publish

Collaborators

  • dolymood