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

xug-v2-ui

v1.0.6

Published

A mobile terminal UI component library based on vue2.x

Downloads

1

Readme

#xug-v2-ui

xug-v2-ui

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

1 安装依赖

cnpm install

推荐使用淘宝 npm 镜像源

2 初始化组件库

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

npm run init

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

3 新建组件

npm run add

4 更新组件库名称

npm run fix

执行完脚本即可全面修改库名前缀,需注意组件库引用iconfont的icon名称也可能被全局替换,需还原成对应iconfont正确名称

5 使用组件库

npm install xug-v2-ui --save
  • 全量导入
# main.js内

import UI from 'xug-v2-ui'
import 'xug-v2-ui/dist/xu-ui.css // 如要自定义主题色,则删除此行
import 'xug-v2-ui/dist/xu-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": "xug-v2-ui",
        "libraryDirectory": "dist/lib",
        "style": (name) => {
          return insertStr(name, name.indexOf('/lib/') + 5, 'theme-chalk/') + '.less'
        }
      }
    ]
  ]
}
  1. 引入基础样式和布局js
# main.js

import 'xug-v2-ui/dist/lib/style/index.css';
import 'xug-v2-ui/dist/xu-ui-flexible.js';

6 自定义主题色

xug-v2-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/xug-v2-ui/dist/lib/theme-chalk/variables.less"), // 固定
      path.resolve(__dirname, "./src/assets/css/variables.less"), // 变量文件位置
    ],
  },
}
  • 全量导入方式
  1. 去除main.js内引入的css文件
# main.js内 删除 import 'xug-v2-ui/dist/xu-ui.css

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