Giter Club home page Giter Club logo

npm-test's Introduction

NPM 发包流程

注册 npm 账号

npm 官网 注册账号

初始化 npm 项目

npm init

这里查看配置说明

主要配置以下字段

  • name
  • version
  • main

git托管

发包

npm login //登录
npm whoami //查看已经登录的账号
npm publish

使用 npm 发布一个 vue 组件(一)

  • 入口文件
import Vue from "vue";
import Test from './Test.vue';

Vue.component(Test.name, Test)

export default Test;
  • 使用
<template>
  <div id="app">
    <Test msg="123" />
  </div>
</template>
<script>
import  Test  from "hedytest";
export default {
  components: {
    Test
  }
};
</script>

使用 npm 发布一个 vue 组件(二)

  • 入口文件
import Test from './Test.vue';

Test.install = Vue => Vue.component(Test.name, Test)

export default Test;
  • 使用
<template>
  <div id="app">
    <Test msg="123" />
  </div>
</template>
<script>
import Vue from "vue";
import Test from "hedytest";

Vue.use(Test);
export default {};
</script>

使用 npm 发布多个 vue 组件(一)

  • 入口文件
import Vue from "vue";
import Test from './Test.vue';
import Info from './Info.vue'

const components = [
  Test,
  Info
]

components.map(component => {
  Vue.component(component.name, component)
})

export {
  Test,
  Info
}
  • 使用
<template>
  <div id="app">
    <Info msg="111" />
    <Test msg="123" />
  </div>
</template>
<script>
import { Info, Test } from "hedytest";
export default {
  components: {
    Info,
    Test
  }
};
</script>

使用 npm 发布多个 vue 组件(二)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.