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

@minar-kotonoha/vue-native-core

v0.3.2

Published

Library with core functionalities to create Vue Native components

Downloads

13

Readme

@minar-kotonoha/vue-native-core

原 git:https://github.com/GeekyAnts/vue-native-core,本项目基于此进行了二次开发。

此 npm 包提供了一个 Vue 构造器,可以将 Vue 的响应式机制、生命周期迁移到 react 上,同时保留了 jsx 写法。

使用方法

父组件:

// Parent.js
import React from 'react';
import { constructor, ref } from '@minar-kotonoha/vue-native-core';
import Child from './Child';

const childRef = ref();
export default constructor({
  data() {
    return {
      showChild: false,
    };
  },
  methods: {
    trigger() {
      this.showChild = !this.showChild;
    },
  },
  mounted() {
    // Vue组件和Vue-React组件以下三种ref使用方式均可,纯React组件只能用第三种。
    childRef.add();
    // childRef.current.add()
    // childRef.current._store.add()
  },
  render() {
    return (
      <div>
        <button onClick={this.trigger}>{this.showChild.toString()}</button>
        {this.showChild && <SubVue ref={childRef} count={1} />}
      </div>
    );
  },
});

子组件:

// Child.js
import React from 'react';
import { constructor } from '@minar-kotonoha/vue-native-core';

export default constructor({
  props: ['count'], // 此处可以注册属性,注册过的属性可以在this中直接访问,也可以用于computed和watch
  data() {
    return {
      a: 0,
    };
  },
  methods: {
    add() {
      this.a++;
    },
  },
  beforeCreate() {
    console.log('beforeCreate');
  },
  created() {
    console.log('created');
  },
  beforeMount() {
    console.log('beforeMount');
  },
  mounted() {
    this.a = this.props.count; // this.props可以拿到所有的属性
    this.a = this.count; // this中可以拿到注册过的属性
    console.log('mounted');
  },
  beforeDestroy() {
    console.log('beforeDestroy');
  },
  destroyed() {
    console.log('destroyed');
  },
  beforeUpdate() {
    console.log('beforeUpdate');
  },
  updated() {
    console.log('updated');
  },
  render() {
    return <button onClick={this.add}>{this.a}</button>;
  },
});

注:由于只是把 Vue 的响应式机制和生命周期移植,最终导出的依然是 React 组件,故并不影响 React 兼容性,Vue 原生组件不能通过 constructor 的方式使用,可以采用原 git 项目中 loader 的方式。

模板指令

为了减少包大小以及考虑到很多用户不喜欢模板指令,本项目默认不包含指令功能,如有需要可以移步@minar-kotonoha/babel-plugin-react-directives