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 🙏

© 2026 – Pkg Stats / Ryan Hefner

generator-uniapp

v1.0.6

Published

Yeoman generator for uniapp

Downloads

21

Readme

Uniapp generator Gitter

一个基于Yeoman的uniapp项目脚手架生成器 - 使您可以使用合理的默认值和最佳实践快速设置项目。

使用用法

安装 yo, generator-uniapp:

npm install -g  yo generator-uniapp
// or
yarn add global yo generator-uniapp

如果您打算使用Sass,则需要首先安装Ruby和Compass:

  • 此处下载或使用 Homebrew 安装 Ruby
  • 使用 gem 安装 compass:
gem install compass

创建一个新目录,并cd进入:

mkdir my-new-project && cd $_

运行 yo uniapp, 可以选择传递应用名称:

yo uniapp [app-name]

运行 yarn 安装依赖关系并 yarn serve 进行预览

Generators

可用的 generators:

App

开始一个新的 uniapp 项目,生成项目基础代码,Generator会自动依赖dcloudio和vuejs的一些模块,包括vuex和 flyio 作为默认的请求工具

例子:

yo uniapp

Component

生成一个全局组建

例子:

yo uniapp:component MyComponent

生成 src/components/my-component/my-component.vue:

<template>
  <view class="my-component"></view>
</template>

<script>
export default {
  name: 'MyComponent',
  props: {}
}
</script>

<style lang="scss" scoped>
  .my-component {

  }
</style>

Page

生成页面并在 src/pages.json 中注册路由

例子:

yo uniapp:page my-page

产生 src/pages/my-page/my-page.vue:

<template>
  <view class="my-page"></view>
</template>

<script>
export default {
  name: 'MyPage',
  data () {
    return {}
  },
  onLoad () {

  },
  methods: {}
}
</script>

<style lang="scss" scoped>
  .my-page {

  }
</style>

通过参数指定是否生成路由和页面标题

Example:

yo uniapp:page my-page --route --title="my page"

产生如上的页面并添加一条路由信息到 src/pages.json

{
  "pages": [
    ...
    {
      "path": "pages/my-page/my-page",
      "style": {
        "navigationBarTitleText": "my page"
      }
    } 
    ...
  ],
  ...
}

当然,您也可以指定生成的子目录。

例子:

yo uniapp:page user/address --route --title="Address"

产生 src/pages/user/address/address.vue:

<template>
  <view class="address"></view>
</template>

<script>
export default {
  name: 'Address',
  data () {
    return {}
  },
  onLoad () {

  },
  methods: {}
}
</script>

<style lang="scss" scoped>
  .address {

  }
</style>

Service

Generates a api service file. 创建一个 api service 文件

例子:

yo uniapp:service home

产生 src/services/home.js:

import request from '@/utils/request'

export function get (params) {
  return request.get('get-url', params, {
    // headers config
  })
}

export function post (parameter) {
  return request.post('post-url', parameter, {
    // headers config
  })
}

Store

Generates a Vuex module file. 创建一个 Vuex Module 文件

例子:

yo uniapp:store cart

产生 src/store/modules/cart.js:

const cart = {
  state: {

  },
  mutations: {

  },
  actions: {

  }
}

export default cart

你需要收到在 store/index.js 中去引入这个文件

Style

创建一个样式文件,默认使用SASS

例子:

yo uniapp:style home

产生 src/styles/home.scss:

.home {

}

生成的样式文件会自动在 src/styles/app.scss 中引入

@import "./iconfont";
@import "./global";
@import "./skeleton";
@import "./home"; // add this line

License

MIT License