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

auto-vue-file

v1.0.1

Published

auto generate vue view or component *.vue file

Downloads

7

Readme

auto-vue-file

auto create .vue file by shell command 通过终端自动创建vue文件

前言:

1: 我们在写xxx.vue页面文件的时候,一般都要写这些重复的代码:

<template>
  <div class="zlj-comp-ct">
    zlj组件
  </div>
</template>
<script>
export default {
  name: 'zlj'
}
</script>
<style lang="scss" scoped>
.zlj-comp-ct {

}
</style>

2:写组件的时候可能还要在components目录下面新建一个目录:xxx,里面是xxx.vue和index.js

比如myForm组件

image.png

// myForm.vue
<template>
  <div class="myForm-comp-ct">
    myForm组件
  </div>
</template>
<script>
export default {
  name: 'myForm'
}
</script>
<style lang="scss" scoped>
.myForm-comp-ct {

}
</style>
// index.js
import myForm from './myForm.vue'
export default myForm

每次都写这些代码,是不是很烦?

主角登场:auto-vue-file

安装

npm install auto-vue-file -g

使用

 auto-vue-file -c

结果

image.png 这样在components目录下面生成myForm文件

参数说明:

名称 | 说明 | 使用例子 ---- | --- | --- component | 创建一个vue组件, 默认在components目录下面 | auto-vue-file -c 或 auto-vue-file --component page | 创建一个vue组件,默认在views目录 | auto-vue-file -p 或 auto-vue-file --page path | 在指定目录创建vue组件,需要提供-c或-p参数| auto-vue-file -c --path ./src/haha 或 auto-vue-file -p --path ./src/haha

更多:

你也可以使用自己的vue模版文件,文件名为auto-vue-file.template.js,存放在项目根目录下面,内容如下

// template.js you can generate
//  auto-vue-file.template.js
        module.exports = {
          vueTemplate: componentName => {
            return `<template>
          <div class="${componentName}-comp-ct">
            ${componentName}组件
          </div>
        </template>
        <script>
        export default {
          name: '${componentName}'
        }
        </script>
        <style lang="scss" scoped>
        .${componentName}-comp-ct {
        
        }
        </style>
        `
          },
         entryTemplate:  componentName => {
            return `import ${componentName} from './${componentName}.vue'
        export default ${componentName}`}
        }

你也可以执行

auto-vue-file --init

自动生成该配置文件:auto-vue-file.template.js

然后改成你自己需要的样子。

github