Skip to content

Web 应用

¥Web Apps

Meteor 允许开发者使用 React、Vue、Blaze、Svelte 和 Solid 等前端框架构建 Web 应用。本节将帮助你使用 React 快速设置新的 MeteorJS 项目。

¥Meteor allows developers to build web applications using front-end frameworks like React, Vue, Blaze, Svelte, and Solid. This section will help you quickly set up a new MeteorJS project using React.

步骤 1:安装 Meteor

¥Step 1: Install Meteor

确保你安装了最新的官方 Meteor 版本。你可以在我们的 docs 中找到安装说明。

¥Ensure you have the latest official Meteor release installed. You can find installation instructions in our docs.

步骤 2:创建新项目

¥Step 2: Create a New Project

要使用 Meteor 和 React 创建新项目,请使用以下命令:

¥To create a new project with Meteor and React, use the command:

shell
meteor create myapp

此命令使用 React 设置 Meteor 项目,允许你立即开始开发。

¥This command sets up a Meteor project with React, allowing you to start developing right away.

你还可以添加 --react 选项以明确选择 React,但它已默认包含在内。如果你更喜欢 TypeScript,只需添加 --typescript 选项。

¥You can also add the --react option to explicitly choose React, but it's already included by default. If you prefer TypeScript, simply add the --typescript option.

shell
meteor create myapp --typescript

附加选项

¥Additional Options

Meteor 提供标志来生成不同类型的应用,例如在项目设置期间选择不同的前端框架或配置。

¥Meteor offers flags to generate different types of apps, like choosing a different front-end framework or configurations during project setup.

Meteor CLI 部分提供了其他选项。

¥Additional options are available in the Meteor CLI section.

步骤 3:在本地运行你的项目

¥Step 3: Run Your Project Locally

导航到你的项目目录并启动 Meteor 服务器:

¥Navigate into your project directory and start the Meteor server:

shell
cd myapp
meteor

如果没有参数,meteor 会在本地开发模式下在当前目录中运行项目。你的应用将在 http://localhost:3000/ 上运行,随时可以开始开发。

¥With no arguments, meteor runs the project in the current directory in local development mode. Your application will be running at http://localhost:3000/, ready for you to begin development.

获取帮助

¥Getting Help

你可以找到有关使用 Meteor 命令行的帮助。只需运行 meteor help 即可查看常用命令列表。如果你需要有关特定命令的详细帮助,请运行 meteor help <command>。例如,meteor help create

¥You can find help for using the Meteor command line. Just run meteor help to see a list of common commands. If you want detailed help about a specific command, run meteor help <command>. For example, meteor help create.

下一步

¥Next Steps