赞
踩
Quasar Framework 是一个基于 Vue.js 的全功能框架,它允许快速构建跨平台的应用程序,包括单页应用(SPA)、服务器端渲染(SSR)、移动应用(使用 Cordova 或 Capacitor)以及 Electron 应用。
安装 Quasar Framework 主要包括安装 Quasar CLI 和创建新项目两个步骤。
首先,在全局环境中安装 Quasar CLI。这可以通过以下命令完成:
npm install -g @quasar/cli
使用 Quasar CLI 创建新项目。根据 Quasar 的最新指南,您可以使用以下命令:
npm init quasar
yarn create quasar
这些命令会启动一个交互式的命令行界面,引导您选择项目的配置选项。
在项目配置过程中,需要做出一系列选择,下面是详细的介绍
PS D:\Code\Python\Scorpio> npm init quasar .d88888b. d88P" "Y88b 888 888 888 888 888 888 8888b. .d8888b 8888b. 888d888 888 888 888 888 "88b 88K "88b 888P" 888 Y8b 888 888 888 .d888888 "Y8888b. .d888888 888 Y88b.Y8b88P Y88b 888 888 888 X88 888 888 888 "Y888888" "Y88888 "Y888888 88888P' "Y888888 888 Y8b ? What would you like to build? » - Use arrow-keys. Return to submit. > App with Quasar CLI, let's go! - spa/pwa/ssr/bex/electron/capacitor/cordova AppExtension (AE) for Quasar CLI Quasar UI kit
输入完成安装指令以后,这里就会出现这样的选择界面,这个选择界面就是我们构建的选择部分
Quasar 提供了多种构建选项,包括单页应用(SPA)、渐进式网页应用(PWA)、服务器端渲染(SSR)、浏览器扩展(BEX)、Electron 应用以及使用 Cordova 或 Capacitor 的移动应用。您的选择应基于您希望开发的应用类型。下面是各个选项的简要说明:
App with Quasar CLI (spa/pwa/ssr/bex/electron/capacitor/cordova): 这是最通用的选项,适用于想要使用 Quasar CLI 构建各种类型应用的开发者。可以在这个选项中进一步选择具体的应用类型,如单页应用(SPA)、渐进式网页应用(PWA)、服务器端渲染(SSR)等。
AppExtension (AE) for Quasar CLI: 这个选项用于开发 Quasar CLI 的扩展。如果想要扩展 Quasar CLI 的功能,可以选择这个选项。
Quasar UI kit: 如果想要开发一个 Quasar UI 组件库或主题,可以选择这个选项。
对于大多数项目来说,第一个选项 “App with Quasar CLI” 是最合适的。在这个选项中,可以选择创建一个标准的前端应用,如 SPA、PWA 或 SSR 等。如果打算开发一个跨平台的移动应用或桌面应用,可以选择 Electron、Cordova 或 Capacitor。
√ What would you like to build? » App with Quasar CLI, let's go!
? Project folder: » quasar-project
接下来就会出现第二个需要填写的内容,这个询问的是你的项目文件夹名称是什么,这里填写你自己的项目文件夹名称
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
? Pick Quasar version: » - Use arrow-keys. Return to submit.
> Quasar v2 (Vue 3 | latest and greatest) - recommended
Quasar v1 (Vue 2)
接下来选择是你需要用来构建的Vue版本,这里我们选择Vue 3进行项目的构建
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
? Pick script type: » - Use arrow-keys. Return to submit.
Javascript
> Typescript
接下来就会询问用来构建的语言是JavaScript
还是Typescript
,这里选择的是Typescript
,
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
? Pick Quasar App CLI variant: » - Use arrow-keys. Return to submit.
> Quasar App CLI with Vite - recommended
Quasar App CLI with Webpack
这里的选择是关于您想要使用的构建工具和开发服务器。Quasar 提供了两种不同的 CLI 变体:一种是基于 Vite 的,另一种是基于 Webpack 的。这两种工具都用于打包和构建您的应用,但它们在某些方面有所不同。
对于大多数新项目来说,“Quasar App CLI with Vite” 通常是推荐的选择,因为它提供了更现代和快速的开发体验。
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
? Package name: » scorpio
这里在询问包的名字,直接回车确认,因为上面Project folder
上面的名字会直接平移到下面
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
√ Package name: ... scorpio
? Project product name: (must start with letter if building mobile apps) » Quasar App
这里需要填写的是展示给用户的名称,如果这里还没有确定就使用代号,可以在后面再进行修改
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
√ Package name: ... scorpio
√ Project product name: (must start with letter if building mobile apps) ... Scorpio
? Project description: » A Quasar Project
这里需要填写的是项目描述
,随便写就可以了
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
√ Package name: ... scorpio
√ Project product name: (must start with letter if building mobile apps) ... Scorpio
√ Project description: ... A Quasar Project
? Author: » Hellohistory <85825011+Hellohistory@users.noreply.github.com>
这里会出现一个作者名,直接回车默认就可以了,没有出现或者需要修改,直接修改就可以了
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
√ Package name: ... scorpio
√ Project product name: (must start with letter if building mobile apps) ... Scorpio
√ Project description: ... A Quasar Project
√ Author: ... Hellohistory <85825011+Hellohistory@users.noreply.github.com>
? Pick a Vue component style: » - Use arrow-keys. Return to submit.
> Composition API - recommended
Composition API with <script setup>
Options API
Class-based
这个选择是关于您希望在 Vue 组件中使用哪种编写风格。Vue 提供了几种不同的方式来定义组件的行为和模板。以下是各个选项的解释:
<script setup>
<script setup>
是一种更简洁的语法,减少了样板代码,并且可以更直观地组织组件的逻辑。data
, methods
, computed
等)组织的。<script setup>
是个不错的选择。一般来说,对于新项目,推荐使用 Composition API 或 Composition API with <script setup>
,因为它们提供了更好的逻辑复用和组织方式。
√ What would you like to build? » App with Quasar CLI, let's go!
√ Project folder: ... scorpio
√ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest)
√ Pick script type: » Typescript
√ Pick Quasar App CLI variant: » Quasar App CLI with Vite
√ Package name: ... scorpio
√ Project product name: (must start with letter if building mobile apps) ... Scorpio
√ Project description: ... A Quasar Project
√ Author: ... Hellohistory <85825011+Hellohistory@users.noreply.github.com>
√ Pick a Vue component style: » Composition API with <script setup>
? Pick your CSS preprocessor: » - Use arrow-keys. Return to submit.
> Sass with SCSS syntax
Sass with indented syntax
None (the others will still be available)
在这里正在选择用于项目的 CSS 预处理器。CSS 预处理器是一种脚本语言,它扩展了 CSS 的功能,并编译成标准的 CSS 文件。预处理器添加了一些有用的特性,如变量、嵌套规则、混合(mixins)和函数等,这些功能可以使您的 CSS 更易于维护和扩展。以下是您提供的选项说明:
大多数现代前端项目倾向于使用 SCSS 语法,因为它结合了 CSS 的直观性和 Sass 的强大功能。
√ What would you like to build? » App with Quasar CLI, let's go! √ Project folder: ... scorpio √ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest) √ Pick script type: » Typescript √ Pick Quasar App CLI variant: » Quasar App CLI with Vite √ Package name: ... scorpio √ Project product name: (must start with letter if building mobile apps) ... Scorpio √ Project description: ... A Quasar Project √ Author: ... Hellohistory <85825011+Hellohistory@users.noreply.github.com> √ Pick a Vue component style: » Composition API with <script setup> √ Pick your CSS preprocessor: » Sass with SCSS syntax ? Check the features needed for your project: » Instructions: ↑/↓: Highlight option ←/→/[space]: Toggle selection a: Toggle all enter/return: Complete answer (*) ESLint (*) State Management (Pinia) ( ) State Management (Vuex) [DEPRECATED by Vue Team] (*) Axios (*) Vue-i18n
在这个界面上,需要选择您的项目所需的特性。每个选项代表一个特定的功能或工具,可以帮助您构建和管理您的应用。以下是这些选项的简要说明:
您可以使用键盘上的箭头键来选择,空格键来切换选项的选择状态。完成后,按回车键继续。
√ What would you like to build? » App with Quasar CLI, let's go! √ Project folder: ... scorpio √ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest) √ Pick script type: » Typescript √ Pick Quasar App CLI variant: » Quasar App CLI with Vite √ Package name: ... scorpio √ Project product name: (must start with letter if building mobile apps) ... Scorpio √ Project description: ... A Quasar Project √ Author: ... Hellohistory <85825011+Hellohistory@users.noreply.github.com> √ Pick a Vue component style: » Composition API with <script setup> √ Pick your CSS preprocessor: » Sass with SCSS syntax √ Check the features needed for your project: » ESLint, State Management (Pinia), Axios, Vue-i18n ? Pick an ESLint preset: » - Use arrow-keys. Return to submit. > Prettier - https://github.com/prettier/prettier Standard Airbnb
在这个步骤中,您正在选择一个 ESLint 预设(preset),这将决定您的项目中将要使用的 ESLint 配置。每个预设都有其自己的代码风格和规则集,下面是您提供的选项的简要说明:
选择哪个预设取决于个人或团队的偏好:
最终的选择应该符合开发习惯和团队的工作流程。可以使用键盘的箭头键进行选择,然后按回车键提交选择。
√ What would you like to build? » App with Quasar CLI, let's go! √ Project folder: ... scorpio √ Pick Quasar version: » Quasar v2 (Vue 3 | latest and greatest) √ Pick script type: » Typescript √ Pick Quasar App CLI variant: » Quasar App CLI with Vite √ Package name: ... scorpio √ Project product name: (must start with letter if building mobile apps) ... Scorpio √ Project description: ... A Quasar Project √ Author: ... Hellohistory <85825011+Hellohistory@users.noreply.github.com> √ Pick a Vue component style: » Composition API with <script setup> √ Pick your CSS preprocessor: » Sass with SCSS syntax √ Check the features needed for your project: » ESLint, State Management (Pinia), Axios, Vue-i18n √ Pick an ESLint preset: » Prettier Quasar • Generating files... - index.html - postcss.config.cjs - quasar.config.js - README.md - .editorconfig - .gitignore - .npmrc - package.json - tsconfig.json - public/favicon.ico - src/App.vue - src/env.d.ts - src/quasar.d.ts - src/shims-vue.d.ts - .vscode/extensions.json - .vscode/settings.json - public/icons/favicon-128x128.png - public/icons/favicon-16x16.png - public/icons/favicon-32x32.png - public/icons/favicon-96x96.png - src/assets/quasar-logo-vertical.svg - src/boot/.gitkeep - src/components/EssentialLink.vue - src/components/ExampleComponent.vue - src/components/models.ts - src/layouts/MainLayout.vue - src/pages/ErrorNotFound.vue - src/pages/IndexPage.vue - src/router/index.ts - src/router/routes.ts - src/css/app.scss - src/css/quasar.variables.scss - src/boot/axios.ts - src/boot/i18n.ts - src/i18n/index.ts - src/i18n/en-US/index.ts - .eslintignore - .eslintrc.cjs - .prettierrc - src/stores/example-store.ts - src/stores/index.ts - src/stores/store-flag.d.ts Quasar • SUCCESS • The project has been scaffolded ? Install project dependencies? (recommended) » - Use arrow-keys. Return to submit. > Yes, use npm No, I will handle that myself
当所有的都选择好以后,建议选择自动使用npm
进行自动安装
这样就可以将Quasar Framework
配置完成了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。