🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@deppon/deppon-button

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@deppon/deppon-button

一个基于Vue的Button组件库

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@deppon/deppon-button

一个基于 Vue 的 Button 组件库,使用 Rollup 打包,支持 Vue 2 和 Vue 3。

为什么使用 3 个版本?

本项目提供了三种模块格式,以满足不同使用场景的需求:

  • es/ (ESM) - ES Module 格式,适用于现代构建工具(webpack、vite、rollup 等),支持 Tree Shaking
  • lib/ (CJS) - CommonJS 格式,适用于 Node.js 环境或传统构建工具
  • dist/ (UMD) - Universal Module Definition 格式,可直接在浏览器中使用,无需构建工具

构建工具会根据使用环境自动选择合适的版本:

  • Node.js → lib/index.js
  • 现代构建工具 → es/index.js
  • 浏览器直接引用 → dist/index.umd.js

安装

npm install @deppon/deppon-button
# 或
yarn add @deppon/deppon-button
# 或
pnpm add @deppon/deppon-button

使用

在 Vue 项目中使用

Vue 2

<template>
  <div>
    <deppon-button type="primary" @click="handleClick">主要按钮</deppon-button>
    <deppon-button type="danger" size="large">危险按钮</deppon-button>
    <deppon-button :loading="isLoading">加载中</deppon-button>
    <deppon-button :disabled="true">禁用按钮</deppon-button>
  </div>
</template>

<script>
import DepponButton from '@deppon/deppon-button';
// 或
import { DepponButton } from '@deppon/deppon-button';

export default {
  components: {
    DepponButton
  },
  data() {
    return {
      isLoading: false
    };
  },
  methods: {
    handleClick() {
      console.log('按钮被点击');
    }
  }
};
</script>

Vue 3

<template>
  <deppon-button type="primary" @click="handleClick">点击我</deppon-button>
</template>

<script setup>
import { ref } from 'vue';
import DepponButton from '@deppon/deppon-button';
// 或
import { DepponButton } from '@deppon/deppon-button';

const handleClick = () => {
  console.log('按钮被点击');
};
</script>

全局注册(Vue 2)

import Vue from 'vue';
import DepponButton from '@deppon/deppon-button';

Vue.component('DepponButton', DepponButton);
// 或使用 kebab-case
Vue.component('deppon-button', DepponButton);

全局注册(Vue 3)

import { createApp } from 'vue';
import DepponButton from '@deppon/deppon-button';

const app = createApp({});
app.component('DepponButton', DepponButton);
// 或使用 kebab-case
app.component('deppon-button', DepponButton);

在浏览器中直接使用(UMD)

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
  <link rel="stylesheet" href="https://unpkg.com/@deppon/deppon-button@latest/dist/index.umd.css">
</head>
<body>
  <div id="app">
    <deppon-button type="primary" @click="handleClick">点击我</deppon-button>
  </div>
  
  <script src="https://unpkg.com/@deppon/deppon-button@latest/dist/index.umd.js"></script>
  <script>
    // 使用 UMD 版本 - Vue 2
    const DepponButtonComponent = window.DepponButton.default || window.DepponButton.DepponButton || window.DepponButton;
    
    if (!DepponButtonComponent) {
      console.error('无法找到 DepponButton 组件', window.DepponButton);
    }
    
    new Vue({
      el: '#app',
      components: {
        'deppon-button': DepponButtonComponent
      },
      methods: {
        handleClick() {
          alert('按钮被点击');
        }
      }
    });
  </script>
</body>
</html>

引入样式

如果使用 ES Module 或 CommonJS 格式,需要单独引入样式:

import DepponButton from '@deppon/deppon-button';
import '@deppon/deppon-button/es/index.css'; // 或 lib/index.css

如果使用 UMD 格式,样式会自动通过 <link> 标签引入。

API

DepponButton Props

属性说明类型默认值
type按钮类型'primary' | 'default' | 'danger' | 'warning''default'
size按钮尺寸'small' | 'medium' | 'large''medium'
disabled是否禁用booleanfalse
loading是否加载中booleanfalse
className自定义类名string''

事件

  • @click - 点击事件,当按钮被点击时触发

开发

# 安装依赖
npm install

# 开发模式(监听文件变化)
npm run dev

# 构建生产版本
npm run build

示例

查看 example/ 目录下的示例文件:

  • index.html - UMD 版本浏览器使用示例

发布到 npm

  • 确保已登录 npm:
npm login
  • 更新版本号:
npm version patch  # 补丁版本 1.0.0 -> 1.0.1
npm version minor  # 次要版本 1.0.0 -> 1.1.0
npm version major  # 主要版本 1.0.0 -> 2.0.0
  • 发布:
npm publish --access public

License

MIT

Keywords

vue

FAQs

Package last updated on 07 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts