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

ponconjs

v1.1.9

Published

前端路由控制系统

Downloads

8

Readme

PonconJS

前端路由控制系统

介绍

  • 面向对象设计
  • 原生 JavaScript 开发
  • 支持页面 hash 监听和路由传参
  • 使用 CSS display 控制页面显示
  • 路由格式:host/[filename]#/target[/args]

说明

  • 入口页面必须是 div.poncon-home.poncon-page

使用方法

安装 PonconJS

  • 使用 <script>​ 标签引入

    <script src="./dist/poncon.min.js"></script>
  • 通过 npm 安装

    npm install ponconjs

创建 poncon​ 对象

注意以下代码需要在页面加载完成后执行,如 window.onload​。

  • 通过 <script>​ 引入时

    const poncon = new Poncon()
  • 使用 JS + Browserify 时

    const ponconjs = require('ponconjs')
    const poncon = new ponconjs.default()
  • 使用 TS + Browserify 时

    import Poncon from 'ponconjs'
    const poncon = new Poncon()

注册页面列表

poncon.setPageList(['home', 'about'])

设置页面事件

poncon.setPage('home', function (target, dom, args) {
    console.log(target, dom, args)
})
poncon.setPage('about', function (target, dom, args) {
    console.log(target, dom, args)
})

启动路由系统(必须在最后执行)

poncon.start()

HTML页面模板

加上 style="display: none;"​ 可以防止页面元素闪烁。

<div class="poncon-home poncon-page" style="display: none;">
    <!-- Your code -->
</div>

<div class="poncon-about poncon-page" style="display: none;">
    <!-- Your code -->
</div>

Demo

打包项目

npm run build

API

getTarget​:获取当前页面标识名称