一、Vue 简介
- Vue 是一款优秀的前端渐进式框架,是目前企业主流的框架技术需求,并且学习难度低。
- 它基于标准的 HTML、CSS、JS 构建,并提供一套声明式、组件化的编程模型。
- 渐进式框架:是一个框架,也是一个生态。可以某个功能单个、模块中使用,甚至在完整的项目中使用。
- Vue 官方文档:https://cn.vuejs.org/guide/introduction
- Vue API 风格:选项式 API 和组合式 API(两种风格不一样但是实现的效果是一致的)
选项式 API(Vue2):
<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):
<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>
6. 开发前的准备工作:
(1)已安装 15.0 以上版本的 Node.js(具体的安装以及配置方法大家可以自行搜索,如果不是安装到 C 盘,就还需要进行系统的配置,不然在你的编程软件中没有办法使用相应的命令) Node.js 官网:https://nodejs.org/zh-cn
(2)创建 Vue 项目:终端中打开存放 Vue 项目的文件夹,创建项目

