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

xg-v-ui

v1.0.5

Published

A mobile terminal UI component library based on vue2.x

Downloads

3

Readme

#xg-v-ui

xg-v-ui

基于vue2.x的移动端UI框架,支持按需加载和自定义主题色。

1 安装依赖

cnpm install

推荐使用淘宝 npm 镜像源

2 初始化组件库

本方案可以定制化组件库前缀, 只需执行完脚本后,输入库名前缀即可,如 xg

npm run init

组件库初始化后,会在 src/config/prefix.js 生成组件库前缀,并引入至组件vue和对应less文件。

3 新建组件

npm run add

4 更新组件库名称

npm run fix

执行完脚本即可全面修改库名前缀

5 使用组件库

npm install xg-v-ui --save
  • 全量导入
# main.js内

import UI from 'xg-v-ui'
import 'xg-v-ui/dist/xg-ui.css // 如要自定义主题色,则删除此行
import 'xg-v-ui/dist/xg-ui-flexible.js'
Vue.use(UI)
  • 按需导入
  1. 安装依赖:
npm install babel-plugin-import -save-dev
  1. 修改babel配置:
# babel.config.js

function insertStr(str, index, newStr){
  return str.slice(0, index) + newStr + str.slice(index)
}

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ],
  "plugins": [
    [
      "import",
      {
        "libraryName": "xg-v-ui",
        "libraryDirectory": "dist/lib",
        "style": (name) => {
          return insertStr(name, name.indexOf('/lib/') + 5, 'theme-chalk/') + '.less'
        }
      }
    ]
  ]
}
  1. 引入基础样式和布局js
# main.js

import 'xg-v-ui/dist/lib/style/index.css';
import 'xg-v-ui/dist/xg-ui-flexible.js';

6 自定义主题色

xg-v-ui采用柔和的浅蓝色为主题色,项目中可以根据实际应用场景合理配色,按照以下方法可以轻松覆盖组件库less变量:

6.1 vue-cli3.0

  1. 安装依赖
cnpm i style-resources-loader -D

# 若运行报错,可能需要安装此依赖
cnpm i vue-cli-plugin-style-resources-loader -D
  1. 新建项目全局less变量文件
# 如:/src/assets/css/variables.less

@btn-primary-bg: red;
  1. 修改 vue.config.js 配置less全局变量
  • 按需导入方式
# vue.config.js
pluginOptions: {
  "style-resources-loader": {
    preProcessor: "less",
    patterns: [
      path.resolve(__dirname, "./node_modules/xg-v-ui/dist/lib/theme-chalk/variables.less"), // 固定
      path.resolve(__dirname, "./src/assets/css/variables.less"), // 变量文件位置
    ],
  },
}
  • 全量导入方式
  1. 去除main.js内引入的css文件
# main.js内 删除 import 'xg-v-ui/dist/xg-ui.css

# vue.config.js
pluginOptions: {
  "style-resources-loader": {
    preProcessor: "less",
    patterns: [
      path.resolve(__dirname, "./node_modules/xg-v-ui/dist/lib/theme-chalk/index.less"), // 固定
      path.resolve(__dirname, "./src/assets/css/variables.less"), // 变量文件位置
    ],
  },
}