当前位置: 首页 > wzjs >正文

做网站图标的软件最大免费广告发布平台

做网站图标的软件,最大免费广告发布平台,旅游网网站建设目的,建网站难不难文章目录 一、Vue 3 基础回顾1. 安装与创建项目2. 基础语法 二、Vue 3 核心 API 全解1. Composition API 详解setupref vs reactivecomputedwatch / watchEffect生命周期钩子 2. 其他实用 APIprovide / injectgetCurrentInstancedefineProps / defineEmits 3. 新特性 三、Vue 3…

文章目录

  • 一、Vue 3 基础回顾
    • 1. 安装与创建项目
    • 2. 基础语法
  • 二、Vue 3 核心 API 全解
    • 1. Composition API 详解
      • setup
      • ref vs reactive
      • computed
      • watch / watchEffect
      • 生命周期钩子
    • 2. 其他实用 API
      • provide / inject
      • getCurrentInstance
      • defineProps / defineEmits
    • 3. 新特性
  • 三、Vue 3 高级特性
    • 1. Script Setup 语法糖
    • 2. 动态组件 & 异步组件
    • 3. 自定义指令
  • 四、性能优化
    • 1. keep-alive
    • 2. 异步组件懒加载
    • 3. v-memo / v-once
  • 五、生态扩展与实战
    • 1. Vue 3 + TypeScript
    • 2. Vue 3 + Axios 封装
    • 3. VueUse 示例
    • 4. Vue 3 + ECharts
  • 六、工具链与部署
    • 1. ESLint + Prettier 配置
    • 2. Vite 打包优化
  • 七、总结

一、Vue 3 基础回顾

1. 安装与创建项目

使用 Vite 快速搭建 Vue 3 项目:

npm create vite@latest my-vue-app
cd my-vue-app
npm install
npm run dev

2. 基础语法

  • v-bindv-model 双向绑定
  • 条件渲染:v-if/v-elsev-show
  • 列表渲染:v-for
  • 事件监听:v-on
  • 样式绑定::class:style

示例:

<template><div><input v-model="message" /><p>{{ message }}</p></div>
</template><script setup>
import { ref } from 'vue'
const message = ref('Hello Vue 3')
</script>

二、Vue 3 核心 API 全解

1. Composition API 详解

setup

export default {setup() {// 逻辑}
}

ref vs reactive

<script setup>
import { ref, reactive } from 'vue'const count = ref(0)
const user = reactive({ name: 'Tom', age: 20 })
</script>

computed

const doubleCount = computed(() => count.value * 2)

watch / watchEffect

watch(() => user.name, (newVal) => {console.log('Name changed:', newVal)
})watchEffect(() => {console.log(user.name)
})

生命周期钩子

onMounted(() => {console.log('Mounted!')
})

2. 其他实用 API

provide / inject

// 父组件
provide('theme', 'dark')// 子组件
const theme = inject('theme')

getCurrentInstance

const { proxy } = getCurrentInstance()
console.log(proxy)

defineProps / defineEmits

<script setup>
const props = defineProps({title: String
})const emit = defineEmits(['submit'])
</script>

3. 新特性

  • Teleport
  • Suspense
  • 多根节点

示例:

<teleport to="body"><div>I am teleported!</div>
</teleport>

三、Vue 3 高级特性

1. Script Setup 语法糖

<script setup>
const msg = 'Hello script setup!'
</script><template><p>{{ msg }}</p>
</template>

2. 动态组件 & 异步组件

<component :is="currentComponent" />

3. 自定义指令

app.directive('focus', {mounted(el) {el.focus()}
})

四、性能优化

1. keep-alive

<keep-alive><component :is="currentView"></component>
</keep-alive>

2. 异步组件懒加载

const AsyncComp = defineAsyncComponent(() =>import('./MyComponent.vue')
)

3. v-memo / v-once

<p v-memo="[count]">{{ count }}</p>
<p v-once>{{ onceValue }}</p>

五、生态扩展与实战

1. Vue 3 + TypeScript

<script setup lang="ts">
const count: Ref<number> = ref(0)
</script>

2. Vue 3 + Axios 封装

// utils/request.js
import axios from 'axios'const instance = axios.create({baseURL: '/api',timeout: 5000
})// 请求拦截
instance.interceptors.request.use(config => {// token 等处理return config
})// 响应拦截
instance.interceptors.response.use(res => res.data,err => Promise.reject(err)
)export default instance
}调用示例:{js
import request from './utils/request'request.get('/user').then(res => {console.log(res)
})

3. VueUse 示例

<script setup>
import { useMouse } from '@vueuse/core'const { x, y } = useMouse()
</script><template><p>Mouse: {{ x }}, {{ y }}</p>
</template>

4. Vue 3 + ECharts

<script setup>
import * as echarts from 'echarts'
import { onMounted } from 'vue'onMounted(() => {const chart = echarts.init(document.getElementById('chart'))chart.setOption({xAxis: { type: 'category', data: ['A', 'B', 'C'] },yAxis: { type: 'value' },series: [{ data: [5, 20, 36], type: 'bar' }]})
})
</script><template><div id="chart" style="width: 600px; height: 400px"></div>
</template>

六、工具链与部署

1. ESLint + Prettier 配置

npm install eslint prettier eslint-config-prettier eslint-plugin-vue -D

根目录添加 .eslintrc.js

module.exports = {extends: ['plugin:vue/vue3-essential', 'prettier']
}

2. Vite 打包优化

  • 开启 gzip 压缩
  • 使用 vite-plugin-compression
npm install vite-plugin-compression -D

vite.config.js:

import viteCompression from 'vite-plugin-compression'export default {plugins: [viteCompression()]
}

七、总结

本文系统介绍了 Vue 3 的基础用法、核心 API、高级特性、性能优化、生态扩展及工具链配置,希望你能通过本教程对 Vue 3 有整体 + 深入的掌握!


http://www.dtcms.com/wzjs/259058.html

相关文章:

  • 网站建设合同图表版百度关键词推广
  • 网站建设原则包括哪些网络营销环境的分析主要是
  • wordpress 命令执行seo顾问
  • 网站建设 团队百度科技有限公司
  • 如何做自己的影视网站友链购买
  • 怎样用手机做网站网站的推广方式有哪些
  • 低代码平台开发seo网站建设优化什么意思
  • 怎么快速做网站怎么宣传网站
  • WordPress开启me360网站seo手机优化软件
  • php做购物网站黑帽seo技术培训
  • 网站做优化的操作图片html网页制作app
  • 山西公司网站建设抖音关键词优化
  • 网站游戏下载360搜索关键词优化软件
  • 怎样编写网站营销网站方案设计
  • 外贸海外网站推广博客优化网站seo怎么写
  • 网络营销网站刷排名有百度手机刷排名
  • 上海 宝安网站建设 网络服务百度商店
  • wordpress后台登录seo链接优化建议
  • 淄博周村专业网站建设公司网页设计费用报价
  • 浏览器打开苏州seo怎么做
  • 武汉个人做网站广州网页制作
  • wordpress 商城安全南宁seo排名外包
  • 自助网站东莞网站建设推广哪家好
  • php网站如何做多语言请简述网络营销的特点
  • wordpress 站点维护广东seo网站优化公司
  • 做网站代理需要办什么营业执照b站推广怎么买
  • 自己建免费网站做外贸怎么推广
  • 外贸网站设计市场调研报告范文大全
  • 网站开发国内外研究动态网站做seo教程
  • 制作绘本怎么做简易长沙排名优化公司