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

ljc-lazy-view

v0.0.4

Published

基于 vue functional 的lazy-view

Downloads

3

Readme

ljc-lazy-view

light-joint-case 轻量的联合的方案,缩写也是俺的名儿,以后会将想要封装的东西放到这个 “ light-joint-case ” 系列里

基于 Vue2 的 functional 组件做的一个路由懒加载函数,非常简单,但是几乎每一个项目都会用到,所以封起来吧

install

npm i ljc-lazy-view

yarn add ljc-lazy-view

Usage

默认用法

import { lazyLoadView } from 'ljc-lazy-view';

const routes = [
  {
    name: 'name',
    path: '/',
    component: () => lazyLoadView(import('@/views/Home.vue')),
  }
]
// ....

自定义用法

import { myLazyLoadView } from 'ljc-lazy-view';
import Loading from './xxx/Loading';
import errorLoading from './xxx/404';

// 这种实现方式你甚至可以为不同的路由添加不一样的loading组件
const lazyView = myLazyLoadView({
  delay: 1000, // 默认为 200ms
  loading: Loading,
  error: errorLoading,
  // ...
});

const routes = [
  {
    name: 'name',
    path: '/1',
    component: () => lazyView(import('@/views/Home.vue')),
  },
  ...
]

不在路由之内

此组件也能用在如tabs之类的组件中,以获取更优的体验。例如:

<div
  v-for="tab in tabs"
  :key="tab.label"
  @click="activeComponent = tab.component"
>
  {{ tab.label }}
</div>
<keep-alive>
  <component :is="activeComponent"></component>
</keep-alive>
import { lazyLoadView } from 'ljc-lazy-view';
export default {
  data() {
    activeComponent: null,
    tabs: [
      { 
        label: 'tabA', 
        component: () => lazyLoadView( import('../xx/xx.vue') )
      },
      // ...
    ],
  }
}

API

myLazyLoadView Options

| key | type | default | description | | :------ | :----: | :-----: | :------------------------------------------------------- | | loading | module | - | 异步加载时候代替显示的组件 | | error | module | - | 加载失败时使用的组件 | | delay | Number | 200 | 延时内异步组件就绪不需要显示,合理的延时可以避免页面闪烁 |

Preview

可以限制网络地浏览我的主页查看效果