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

cgx-component

v0.0.3

Published

通过组件二次封装库,包含一些hooks、directives、components

Downloads

47

Readme

简介

cgx-components 是一个基于 Vue 3 的二次封装库,它提供了许多可用的工具,包括组件、指令、钩子。 cgx-components 的目标是让开发者能够快速地构建出高质量、易维护的 Vue 应用程序。

// 引入样式
import "cgx-component/dist/style.css";

// 引入Element plus样式
import "element-plus/dist/index.css";
// 引入组件、钩子、类型
import { CTable, DefaultPaginationData, usePagination } from "cgx-component";
//注册指令
import { createApp } from "vue";
import App from "./App.vue";
import "element-plus/dist/index.css";
import ElementPlus from "element-plus";
import "cgx-component/dist/style.css";
import { vSlider, vWaves, vResize, vFlip } from "cgx-component";

const app = createApp(App);

app.use(ElementPlus);
app.directive("slider", vSlider);
app.directive("waves", vWaves);
app.directive("resize", vResize);
app.directive("flip", vFlip);
app.mount("#app");

指令 基础用法

<!-- 注册指令之后即可直接使用 -->
<script setup lang="ts">
const handleResize = () => {
  console.log("触发回调");
};

const flip = ref(false);

const handleFlip = () => {
  flip.value = !flip.value;
};
</script>

<template>
  <div v-resize="handleResize">
    <div
      @click="handleFlip"
      v-flip="flip"
      style="height: 300px; width: 300px; cursor: pointer"
    >
      <div class="front">front</div>
      <div class="back">back</div>
    </div>
    <div
      v-slider
      v-waves
      v-for="i in 1000"
      style="
        height: 300px;
        margin-top: 10px;
        width: 300px;
        background-color: aqua;
        cursor: pointer;
      "
    ></div>
  </div>
</template>

<style scoped>
.front {
  width: 100%;
  height: 100%;
  background-color: aqua;
}
.back {
  width: 100%;
  height: 100%;
  background-color: red;
}
</style>

JSON化elementui二次封装 基础用法

<script setup lang="ts">
import { ref, h } from "vue";
import { CTable, DefaultPaginationData} from "cgx-component";

//储存表格数据
const tableRef = ref();
const tableData = ref<any[]>([]);
const loading = ref(false);

//表格字段
const columns = [
  {
    label: "名字",
    prop: "name",
  },
  {
    label: "备注",
    prop: "remark",
  },
  {
    label: "状态",
    prop: "status",
    isVNode: true,
    render(row: any) {
      return h("div", row.status === "1" ? "启用" : "禁用");
    },
  },
];

//储存当前分页信息
let savePageData: DefaultPaginationData;

//获取数据
const getTableData = (page: DefaultPaginationData) => {
  loading.value = true;
  savePageData = page;
  // 模拟数据请求
  tableData.value = [
    { name: "张三", age: 25 },
    { name: "李四", age: 30 },
  ];
  loading.value = false;
  savePageData.total = tableData.value.length;
};

const handleClick = () => {
  tableRef.value.queryList();
};

</script>

<template>
  <div>
    <el-button @click="handleClick" type="success">获取数据</el-button>
    <CTable
      ref="tableRef"
      :loading="loading"
      :tableData="tableData"
      :columns="columns"
      @queryList="getTableData"
    ></CTable>
  </div>
</template>