@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.06latest

Version History

VersionDownloads (Last 7 Days)Published
0.9.06
0.8.03
0.7.03
0.6.43
0.6.35
0.6.25
0.6.15
0.6.05
0.5.15
0.5.05
0.4.33
0.4.25
0.4.13
0.4.03
0.3.03
0.2.05
0.1.13
0.0.15

Package Sidebar

Install

npm i @uni-component/vue

Weekly Downloads

75

Version

0.9.0

License

MIT

Unpacked Size

27.7 kB

Total Files

12

Last publish

Collaborators

  • dolymood