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

fast-vue-f-link

v1.0.0

Published

Vue 组件获取其它组件实例插件 (无视组件层级、子孙关系),但不支持响应式,若要支持响应式获取和通知请看 `fats-vue-f-ref` 插件

Downloads

1

Readme

p-f-link 组件获取其它组件实例插件 (无视组件层级、子孙关系)

前言:我们在使用Vue进行开发时如何只是想单纯的去获取一个和自身组件没有层级关系或者层级较深的其它组件实例然后对它进行一些函数操作,那么可以使用这个插件来方便的达到这样一个目的。

注意:

如果需要同时获取某一组的组件实例请使用 p-f-unicom 插件,p-f-link 只提供获取单个组件实例的功能。

p-f-link 自定义插件:
  1. 它是Vue.js的一个自定义插件,获取其它组件实例 (无视组件层级、子孙关系)。
功能:
  1. 任意一个Vue组件获取任意一个Vue组件的实例。
  2. 组件销毁时自动销毁存放在插件中受管理的当前组件的实例。
使用:

main.js 注册p-f-link插件

link是插件内置的名称,如果需要修改可以在Vue.use时自定义。

// 导入
import link from 'fast-vue-f-link'
// 使用
Vue.use(link, {name: 'link'})
Vue组件内部使用

APP.vue

<template>
  <div id="app">
    <!--定义一个 link 属性-->
    <show-component v-if="b" link="show-component-link"></show-component>
    <link-index></link-index>
  </div>
</template>
<script>
import showComponent from './components/test/Index.vue'
import linkIndex from './components/link/index.vue'
export default {
  components: {
    showComponent,
    linkIndex
  },
  data () {
    return {
      b: true
    }
  },
  mounted () {
    setTimeout(() => {
      // 销毁组件后在获取会返回 undefined ,证明存放在 p-f-link 插件中的组件实例已经自动销毁了
      this.b = false
    }, 3000);
  }
}
</script>
<style></style>

showComponent.vue

<template>
  <div>
    link 属性要获取的组件
  </div>
</template>

<script>
export default {
  components: {},
  data () {
    return {}
  },
  mounted () {},
  methods: {
    
  }
}
</script>

<style scoped>
</style>

linkIndex

<template>
  <div>
    <button @click="doLink">link 插件测试</button>
  </div>
</template>

<script>
export default {
  data () {
    return {}
  },
  methods: {
    doLink () {
      const vm = this.getLinkComponent('show-component-link')
      // show-component-link 对应的组件销毁后返回 undefined,存在则返回组件实例
      console.info(vm); 
    }
  }
}
</script>

<style></style>