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

sub-components

v1.0.3

Published

A Vue.js project

Downloads

6

Readme

sub-components

类似于Vue中component的理念。渲染一个“元组件”为动态组件。根据传入 com 的值,来决定哪个组件被渲染。

区别点在于sub-components支持不定层级的“元组件”的渲染。

用法示例

  1. npm install sub-components
  2. 在页面中引用sub-components和元组件(以Tabs组件为例)
import SubComponents from "sub-components";
import Tabs from "./components/tabs";
export default {
  components: {
    SubComponents,
    Tabs,
  },
  1. 在html中使用该组件,com中传入元组件的名称
<sub-components
  com="Tabs"
  :dataList="tabData"
  transferLevel
  @switchTab="switchTab"
>
  <p>{{ content }}</p>
</sub-components>
<script>
export default {
  // ...
  data() {
    return {
      tabData: [
        [1, 2, 3],
        [1, 2],
        [1, 2, 3, 4]
      ],
      path: [0, 0, 0],
    };
  },
  computed: {
    content: function() {
      return 'content' + this.path.reduce((acc, cur) => acc + '-' + (cur + 1), '');
    },
  },
  methods: {
    switchTab(data) {
      const { level, index } = data;
      this.$set(this.path, level, index);
    },
  },
}
</script>
  1. 效果展示

属性

Attributes

| 参数 | 说明 | 类型 | 默认值 | 必选 | | ------------- | ---------------------------- | --------------- | -------------------------------------------- | ---- | | com | 元组件的名称 | string | | 必选 | | dataType | 元组件的属性名 | string | "data" | | | dataList | 元组件的数据列表 | array | number | 1 | 必选 | | range | 层级([min, max]) | array | [this.dataList.length, this.dataList.length] | | | transferLevel | 是否传递层级索引level到组件props | boolean | false | | | config | 具体配置 | Object | {} | |

slots

| Name | 说明 | scoped | | ------------ | ------------------------------------------------------------ | --------------------------------------------------- | | - | 自定义内容(default) | - | | levelControl | 层级控制(index 当前层级索引;increase 可增大;decrease 可减小) | {index: number,increase: boolean,decrease: boolean} |

本地开发

  • git clone https://github.com/xichi/vue-sub-components
  • npm install
  • npm run dev