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

vue-cli-plugin-pc

v0.2.0

Published

基于Vue CLI快速生成项目

Downloads

27

Readme

vue-cli-plugin-pc

[toc]

功能

  • 添加自动注册组件功能
  • 添加 svg sprite 功能

使用

# 创建你的项目
vue create project

# 对项目添加 vue-cli-plugin-pc 的配置
vue add pc

自动注册组件功能

在插件安装完成后,项目的 assets/js/ 下会添加 autoComponents.js,此js的功能是帮助你自动对 **src/components/**下的组件进行全局注册。

然后我们可以在我们的项目中直接使用组件。

此时,需要注意的是组件的生成规范,以下是一个常用组件的目录结构

-- svgIcon
    |-- index.vue 这是组件的入口
    |-- readme.md 添加组件使用文档

index.vue 模板:

<template>
    <svg><use :xlink:href="iconName"/></svg>
</template>

<script>
export default {
    // 组件名,建议:目录名-com:
    name: 'svg-icon-com',
    props: {
        // ...
    },
    data () {
        return { //... }
    }
}
</script>

组件调用规则:

依照文件夹的名称来使用,文件夹以驼峰命名;使用时,以 - 分隔

<!-- svgIcon -->
<svg-icon />

<!-- SvgIcon -->
<svg-icon />

<!-- svgIcon2 -->
<svg-icon2 />

<!-- mycomponents -->
<mycomponents></mycomponents>

注意:如果页面无法找到自动的组件,可以将项目重启一下。

SVG Sprite

在你添加了插件之后,插件会在你以下目录中添加相应的文件

-- src 
  |-- assets
  |   |-- icons `New` 添加图标目录
  |        |-- svg 图标库,将你需要使用的图标都放在这
  |        |-- index.js SVG Sprite 脚本
  |-- components 
      |-- svgIcon `New` 图标组件
  1. 将你需要的 SVG 图标添加到 src/assets/icons/svg 目前中
  2. 在页面中使用 svgIcon组件来处理图标
<template>
    <svg-icon icon="search"/>
</template>