npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-jsx

v0.2.9

Published

## 目标 简化 vue createElement 写法,从而可以手写 render vnode。

Downloads

58

Readme

vue-jsx

目标

简化 vue createElement 写法,从而可以手写 render vnode。

安装

npm install --save vue-jsx

使用

import jsx from 'vue-jsx'

const HelloWorld = {
  props: {
    msg: String,
  },
  render (h) {
    jsx.use(h)
    
    return jsx.create('div', {
      style_color:'red', 
      classes: 'hello world',
    }, this.msg)
  }
}

Api

1、jsx.use
  描述:指定依赖的 vue h
  用法:jsx.use(h)

2、jsx.create
  描述:创建 vnode 节点
  用法:
    jsx.create('div')

    // class 的简写模式
    jsx.create('div.hello + world')
    
    jsx.create('div', {
      // vif,就是 v-if
      vif: false,

      // vmodel,就是 v-model
      // 最多支持4个参数,vmodel: [this, 'val' ,'modelProp', 'modelEvent']
      vmodel: [this, 'val'],

      classes: 'hello world',
      class_hello: true,
      style_color: 'red',
      attrs_id: 'my_id',
      props_msg: 'hello, world',
      domProps_value: 'input value',
      on_click () {},
      nativeOn_click () {},
    })

    jsx.create('div', {style_color:'red'}, 'nihao', 'nihao2')

3、jsx.bind
  描述:构建快捷方式
  用法:
    const div = jsx.bind('div')
    const HelloWorld = jsx.bind('hello-world')

    const App = {
      render (h) {
        jsx.use(h)

        return div({style_color:'red'}, 
          HelloWorld()
        )
      }
    }
  备注:实际上 jsx 内置 bind 了大部分常用 dom 元素,比如 a,b,button,dd,div,dl,dt,em,form,i,iframe,img,input,textarea,label,li,ol,optgroup,option,p,select,span,table,th,thead,tbody,tr,td,col,colgroup,ul,h1,h2,h3,h4,h5,h6

演示

import jsx from 'vue-jsx'

const {div, h2, p, span, img} = jsx

const HelloWord = {
  props: {
    data: Array,
  },
  render (h) {
    jsx.use(h)

    return div('.hello-world'
      h2('hello-world-title'),
      div('.hello-world-list'
        ...this.data.map(item => {
          return div('.hello-world-item',
            img({attrs_src: item.imgSrc}),
            p(item.content),
          )
        })
      )
    )
  }
}