# @cfcs/vue3 中文文档

规范地址：https://npmcn.com/package/%40cfcs/vue3/

版本：0\.1\.0
npm 元数据更新时间：2023-02-24T13:04:45.416Z
中文译文更新时间：2026-11-09T08:31:45.102Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40cfcs/vue3
原文对照：https://npmcn.com/package/%40cfcs/vue3/?lang=original
项目主页：https://naver.github.io/cfcs
源码仓库：https://github.com/naver/cfcs#main

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：39.1 kB，17 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2022-07-22T02:26:33.760Z
- 最新版本发布：2023-02-24T13:04:45.310Z
- 近 30 天下载量：17067（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：26（近 12 个月 0 个）

## 中文简介

写入一次,创建支持React,Vue,Svelte等的框架组件.

## 安装

```sh
npm install @cfcs/vue3
```

也可以使用：`pnpm add @cfcs/vue3`、`yarn add @cfcs/vue3`、`bun add @cfcs/vue3`

## README

## ![](https://raw.githubusercontent.com/naver/cfcs/main/images/logo.png)  
[Vue 3 的跨框架组件](https://npmcn.com/package/%40cfcs/vue3/#)

写入一次,创建支持React,Vue,Svelte等的框架组件.

[![](https://img.shields.io/npm/v/@cfcs/vue3.svg?style=flat-square&color=00d8ff&label=version&logo=NPM)](https://www.npmjs.com/package/@cfcs/vue3)  ![](https://img.shields.io/badge/language-typescript-blue.svg?style=flat-square)  [![GitHub](https://img.shields.io/github/license/naver/cfcs.svg?style=flat-square&label=%F0%9F%93%9C%20license&color=08CE5D)](https://github.com/naver/cfcs/blob/main/LICENSE) 

### [演示](https://naver.github.io/cfcs/) 编号 : [API 密码](https://naver.github.io/cfcs/docs/api/Core/Reactive/Function/reactive) 编号 : [教学](https://naver.github.io/cfcs/docs)

## \* 安装

```sh
# >= 2.7
$ npm install @cfcs/vue3
# < 2.7
$ npm install @cfcs/vue3
```

## 如何使用

Vue 3 组件可以通过使用 `useReactive` 结束 `REACTIVE_ADAPTER`(单位:千美元)[使用 @ cfcs/ core 制作](https://github.com/naver/cfcs/blob/main/reactive.md))常数.

### 适配器

```js
import { reactive } from "@cfcs/core";

const REACTIVE_ADAPTER = ({
  emit,
  onInit,
  setEvents,
  setMethods,
}) => {
  setEvents(["event1"]);
  setEvents(["method1"]);

  const obj = reactive({
    value1: 1,
    method1() {
      console.log("method1");
    },
  });

  const inst = new YourModule();

  onInit(() => {
    requestAnimationFrame(() => {
      value1.current = 2;

      // emit `event1` event externally
      emit("event1", e);
    });
  });

  // Returns a reactive value.
  return obj;
};
```

### 构成部分

```ts
import { REACTIVE_ADAPTER } from "your-module";
import { useReactive, ReactiveAdapterResult } from "@cfcs/vue3";

// The result value of useReactive can be exposed as a type.
export type ReactiveComponentResult = ReactiveAdapterResult<typeof REACTIVE_ADAPTER>;

// Reactive Component can be created through useReactive.
export function useReactiveComponent(props) {
  return useReactive(REACTIVE_ADAPTER, () => props);
}
```

### 应用

```html
<script>
export default {
  setup() {
    const {
      // state
      value1,
      // events
      onEvent1,
      // methods
      method1,
    } = useReactiveComponent({});

    // use state
    console.log(value1.value);

    // use event
    onEvent1(e => {
      console.log(e);
    };

    // use method
    method1();
  },
};
</script>
```

## \* 反馈

请存档 [问题](https://github.com/naver/cfcs/issues)。 。 。 .

## 许可证

`cfcs` 将在 [麻省理工学院许可证](https://github.com/naver/cfcs/blob/main/LICENSE)。 。 。 .

```
CFCs
Copyright (c) 2023-present NAVER Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

## 常见问题

### @cfcs/vue3 是什么？

写入一次,创建支持React,Vue,Svelte等的框架组件\.

### 如何安装 @cfcs/vue3？

在项目目录运行 npm install @cfcs/vue3，或使用 pnpm add / yarn add / bun add。

### @cfcs/vue3 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @cfcs/vue3 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @cfcs/vue3 可以商用吗？

@cfcs/vue3 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @cfcs/vue3 的下载量有多少？

根据 npm 官方下载统计，@cfcs/vue3 在 2026/10/10 – 2026/11/08 这 30 天内被下载 17,067 次，日均约 569 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @cfcs/vue3 还在维护吗？

最新版本 0\.1\.0 发布于 2023/02/24（3 年前）；至今共发布 26 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/07/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

