01 Vue3基础入门

目录

Vue3基础入门

Vue代码编写风格

前提条件

创建Vue项目

开发环境

项目文件说明

Vue代码编写风格

  • 选项式API --> vue2
javascript 复制代码
<script>
 export default {
   data() {
     return {
       count: 0
     }
   },
   methods: {
     increment() {
       this.count++
     }
   },
   mounted() {
     console.log(`The initial count is ${this.count}.`)
   }
 }
 </script>
 ​
 <template>
   <button @click="increment">Count is: {{ count }}</button>
 </template>
  • 组合式API --> vue3
javascript 复制代码
 <script setup>
 import { ref, onMounted} from 'vue'
 const count = ref(0)
 function increment() {
   count.value++
 }
 onMounted(() => {
   console.log(`The initial count is ${count.value}.`)
 })
 </script>
 ​
 <template>
   <button @click="increment">Count is: {{ count }}</button>
 </template>

前提条件

  • 安装15.0或更高版本的Node.js

创建Vue项目

  • cd进入你的项目所在文件夹
bash 复制代码
 npm init vue@latest
  • 这个指令将会安装并执行create-vue,它是Vue官方的项目脚手架工具。你将会看到一些诸如TypeScript和测试支持之类的可选功能提示。
bash 复制代码
 √ project name: ... <your-project-name>
 √ Add TypeScript? ... No / Yes
 √ Add JSX Support? ... No / Yes
 √ Add Vue Router for single Page Application development? ... No / Yes
 √ Add Pinia for state management? ... No / Yes
 √ Add Vitest for Unit testing? ... No / Yes
 √ Add Cypress for both Unit and End-to-End testing? ... No / Yes
 √ Add ESLint for code quality? ... No / Yes
 √ Add Prettier for code formatting? ... No / Yes
 ​
 scaffolding project in ./<your-project-name>...
 Done.
  • 根据提示,继续运行,值得注意的是,npm可用cnpm,因为cnpm是npm的国内镜像,能加速下载

cnpm 的安装与使用\] https://developer.aliyun.com/article/1599824 ```bash cd vue-base npm install npm run dev ``` * 浏览器打开这个网址,说明创建成功 ![](https://i-blog.csdnimg.cn/direct/7e5a9ea11fbc43a6a742b82a23780fb1.png) ![](https://i-blog.csdnimg.cn/direct/6395c0b79b9d4607ad83692a324bcf9e.png) ### 开发环境 推荐的IDE配置是`Visual Studio Code` + `Volar`拓展 ### 项目文件说明 ```bash .vscode --- VSCode工具的配置文件夹 node-modules --- Vue项目的运行依赖文件夹 public --- 资源文件夹(浏览器图标) src --- 源码文件夹 .gitignore --- git忽略文件 index.html --- 入口HTML文件 package.json --- 信息描述文件 README.md --- 注释文件 vite.config.js --- Vue配置文件 ```

相关推荐
RuoyiOffice1 天前
SpringBoot+Vue3 企业云盘系统设计:文件上传+共享权限+收藏分类+5GB空间控制——从“网盘孤岛”到“企业知识底座”
spring boot·uni-app·vue·文件管理·云盘·网盘·ruoyioffice
T畅N2 天前
审批流设计器(前端)
前端·elementui·vue·html·流程图·js
吴声子夜歌2 天前
Vue3——使用Mock.js
javascript·vue·mock.js
abcnull2 天前
Springboot+Vue2的Web项目小白入门Demo快速学习!
java·elementui·vue·maven·springboot·web·小白
RuoyiOffice2 天前
SpringBoot+Vue3 企业假期余额系统设计:账户、流水、预占、销假退回与到期清零全链路拆解
spring boot·后端·spring·vue·hr·企业管理软件·ruoyioffice
abcnull3 天前
传统的JavaWeb项目Demo快速学习!
java·servlet·elementui·vue·javaweb
RuoyiOffice3 天前
SpringBoot+Vue3 实现 OA 公文外来文与归档台账:外部收文、BPM办理、三类公文统一归档
spring boot·微服务·uni-app·vue·ruoyi·anti-design-vue·ruoyioffice
RuoyiOffice4 天前
SpringBoot+Vue3 企业考勤如何处理法定假期?节假日方案、调休补班与工作日判断链路拆解
spring boot·后端·vue·anti-design-vue·ruoyioffice·假期·人力
REDcker5 天前
浏览器端Web程序性能分析与优化实战 DevTools指标与工程清单
开发语言·前端·javascript·vue·ecmascript·php·js
jay神6 天前
基于团队模式的C程序设计课程辅助教学管理系统
java·spring boot·vue·web开发·管理系统