Vue3知识点梳理

【前端学习】尚硅谷Vue3全部知识点汇总(完整版) vue3全部知识点汇总 阅读详情

注:纯手打,如有错误欢迎评论区交流!
转载请注明出处:https://blog.youkuaiyun.com/testleaf/article/details/148056625
编写此文是为了更好地学习前端知识,如果损害了有关人的利益,请联系删除!
本文章将不定时更新,敬请期待!!!
欢迎点赞、收藏、转发、关注,多谢!!!

一、Vue2选项式API和Vue3组合式API

1、Vue 2 选项式 API(Options API)​

<template>
  <div>
    <p>{{ message }}</p>
    <button @click="reverseMessage">Reverse</button>
  </div>
</template>

<script>
export default {
  data() {
    return { message: "Hello Vue 2!" };
  },
  methods: {
    reverseMessage() {
      this.message = this.message.split('').reverse().join('');
    }
  },
  mounted() {
    console.log("Component mounted!");
  }
};
</script>

2、Vue 3 组合式 API(Composition API)

<template>
  <div>
    <p>{{ message }}</p>
    <button @click="reverseMessage">Reverse</button>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue';

export default {
  setup() {
    const message = ref("Hello Vue 3!");

    const reverseMessage = () => {
      message.value = message.value.split('').reverse().join('');
    };

    onMounted(() => {
      console.log("Component mounted!");
    });

    return { message, reverseMessage };
  }
};
</script>

3、核心对比

​​对比维度​​​​Vue 2 选项式 API​​​​Vue 3 组合式 API​​
​​​​代码组织方式​​​​按选项(data、methods 等)分类​​按逻辑功能聚合(setup() 函数内)
​​​​逻辑复用​​​​依赖 mixins(易冲突)​​自定义组合函数(无冲突)
​​​​TypeScript 支持​​​​ 较弱(this 类型推断困难)​​优秀(ref、reactive 类型明确)
​​​​适用场景​​​​ 简单组件、小型项目​​复杂组件、大型项目、逻辑复用需求
​​​​响应式系统​​​​基于 Object.defineProperty(Vue 2)​​ 基于 Proxy(Vue 3,性能更好)

二、Vue3相比于Vue2的优势

1、更容易维护:组合式API、更好的TypeScript支持;
2、更快的速度:重写diff算法、模板编译优化、更高效的组件初始化;
3、更优的数据响应式:Proxy;
4、更小的体积:良好的TreeShaking、按需引入;

三、使用create-vue搭建Vue3项目

1、认识create-vue
create-vue是Vue官方新的脚手架工具,底层切换到了 vite (下一代前端工具链),为开发提供极速响应。
而vue-cli的底层是webpack。
2、使用create-vue创建项目

npm init vue@latest

3、项目关键文件

  • vite.config.js - 项目的配置文件:基于vite的配置
  • package.json - 项目包文件:核心依赖项变成了 Vue3.x 和 vite
  • main.js - 入口文件:createApp函数创建应用实例
  • app.vue - 根组件:SFC单文件组件 script - template - style
    • 变化一:脚本script和模板template顺序调整
    • 变化二:模板template不再要求唯一根元素
    • 变化三:脚本script添加setup标识支持组合式API
  • index.html - 单页入口:提供id为app的挂载点

四、组合式API - setup选项

1、写法

<script>
  export default {
    setup(){
      
    },
    beforeCreate(){
      
    }
  }
</script>

2、执行时机
在beforeCreate钩子之前执行;
3、setup中写代码的特点
在setup函数中写的数据和方法需要在末尾以对象的方式return,才能给模版使用;
4、<script setup>语法糖
script标签添加 setup标记,不需要再写导出语句,默认会添加导出语句;

<script setup>
  const message = 'this is message'
  const logMessage = ()=>{
    console.log(message)
  }
</script>

五、组合式API - reactive和ref函数

1、reactive
接受对象类型数据的参数传入并返回一个响应式的对象;

import { reactive } from 'vue'

const state = reactive({
  count: 0,
  message: 'Hello Vue!'
})

// 访问和修改
state.count++
console.log(state.message)

2、ref
接收简单类型或者对象类型的数据传入并返回一个响应式的对象;

import { ref } from 'vue'

const count = ref(0)
const message = ref('Hello Vue!')

// 访问和修改
count.value++ // 注意需要通过.value访问
console.log(message.value)

3、比较与选择

特性reactiveref
适用类型对象任意值
访问方式直接访问.value
模板中使用直接使用自动解包
解构响应性丢失保持

4、使用建议

  • 当需要管理一组相关状态时,使用reactive
  • 当需要管理单个原始值时,使用ref
  • 在组合式函数中返回状态时,通常使用ref以保持灵活性

六、组合式API - computed

计算属性基本思想和Vue2保持一致,组合式API下的计算属性只是修改了API写法;
基本用法:

import { ref, computed } from 'vue'

const count = ref(0)

// 创建一个计算属性
const doubleCount = computed(() => count.value * 2)

console.log(doubleCount.value) // 0
count.value++
console.log(doubleCount.value) // 2

可写计算属性:

const firstName = ref('John')
const lastName = ref('Doe')

const fullName = computed({
  get() {
    return `${firstName.value} ${lastName.value}`
  },
  set(newValue) {
    [firstName.value, lastName.value] = newValue.split(' ')
  }
})

fullName.value = 'Jane Smith' // 会自动更新firstName和lastName

七、组合式API - watch

1、基本用法

import { ref, watch } from 'vue'

const count = ref(0)

// 基本watch用法
watch(count, (newValue, oldValue) => {
  console.log(`count从${oldValue}变为${newValue}`)
})

2、观察多个源

const firstName = ref('')
const lastName = ref('')

// 观察多个ref
watch([firstName, lastName], ([newFirst, newLast], [oldFirst, oldLast]) => {
  console.log(`名字从${oldFirst} ${oldLast}变为${newFirst} ${newLast}`)
})

3、观察响应式对象

const state = reactive({
  user: {
    name: 'Alice',
    age: 25
  }
})

// 深度观察对象
watch(
  () => state.user,
  (newUser, oldUser) => {
    console.log('用户信息变化:', newUser)
  },
  { deep: true }
)

4、立即执行

const data = ref(null)

// 立即执行回调
watch(
  data,
  (newValue) => {
    console.log('数据:', newValue)
  },
  { immediate: true }
)

5、观察getter函数

const state = reactive({
  items: [],
  total: 0
})

// 观察计算值
watch(
  () => state.items.length,
  (newLength) => {
    console.log(`项目数量变为: ${newLength}`)
  }
)

6、停止观察

const stop = watch(count, (newValue) => {
  if (newValue > 10) {
    stop() // 停止观察
    console.log('已达到最大值,停止观察')
  }
})

7、实际应用示例

<template>
  <div>
    <input v-model="searchQuery" placeholder="搜索...">
    <div v-if="isSearching">搜索中...</div>
    <ul v-else>
      <li v-for="result in searchResults" :key="result.id">
        {{ result.name }}
      </li>
    </ul>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'

const searchQuery = ref('')
const searchResults = ref([])
const isSearching = ref(false)

// 防抖搜索
watch(searchQuery, async (newQuery) => {
  if (!newQuery.trim()) {
    searchResults.value = []
    return
  }
  
  isSearching.value = true
  try {
    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 300))
    searchResults.value = await mockSearch(newQuery)
  } finally {
    isSearching.value = false
  }
})

async function mockSearch(query) {
  // 模拟API返回
  return [
    { id: 1, name: `${query} 结果1` },
    { id: 2, name: `${query} 结果2` }
  ]
}
</script>

8、watchEffect
与watch相关的还有watchEffect,它会立即执行一次,并自动追踪其依赖:

import { ref, watchEffect } from 'vue'

const count = ref(0)

watchEffect(() => {
  console.log(`count的值是: ${count.value}`)
})

9、比较watch和watchEffect

特性watchwatchEffect
惰性执行是否(立即执行)
指定观察源需要自动追踪
访问旧值可以不可以
初始化执行需要配置immediate总是执行

10、最佳实践

  • ​​避免过度使用​​:优先使用计算属性,只在需要副作用时使用watch;
  • ​​清理副作用​​:在回调中执行异步操作时,注意清理之前的操作;
  • ​​性能优化​​:对于复杂对象,考虑使用{ deep: true }或特定getter函数;
  • ​​组件卸载时​​:在setup()中创建的watch会自动停止,手动创建的记得清理;

八、组合式API - 生命周期函数

在Vue 3的组合式API中,生命周期钩子是通过特定的函数来访问的,而不是Options API中的选项形式。
1、主要生命周期函数
onBeforeMount 和 onMounted:

import { onBeforeMount, onMounted } from 'vue'

onBeforeMount(() => {
  console.log('组件即将挂载')
})

onMounted(() => {
  console.log('组件已挂载')
  // 可以访问DOM元素
})

onBeforeUpdate 和 onUpdated:

import { onBeforeUpdate, onUpdated } from 'vue'

onBeforeUpdate(() => {
  console.log('组件即将更新')
})

onUpdated(() => {
  console.log('组件已更新')
  // DOM已更新完成
})

onBeforeUnmount 和 onUnmounted:

import { onBeforeUnmount, onUnmounted } from 'vue'

onBeforeUnmount(() => {
  console.log('组件即将卸载')
})

onUnmounted(() => {
  console.log('组件已卸载')
  // 清理定时器、事件监听等
})

onErrorCaptured:

import { onErrorCaptured } from 'vue'

onErrorCaptured((err, instance, info) => {
  console.error('捕获到错误:', err)
  // 返回false阻止错误继续向上传播
  return false
})

2、新增的生命周期函数
Vue 3还引入了两个新的生命周期函数:
onRenderTracked (开发模式):

import { onRenderTracked } from 'vue'

onRenderTracked((event) => {
  console.log('跟踪到依赖:', event)
})

onRenderTriggered (开发模式):

import { onRenderTriggered } from 'vue'

onRenderTriggered((event) => {
  console.log('触发重新渲染:', event)
})

3、组合式API与Options API生命周期对应关系

组合式APIOptions API
onBeforeMountbeforeMount
onMountedmounted
onBeforeUpdatebeforeUpdate
onUpdatedupdated
onBeforeUnmountbeforeUnmount
onUnmountedunmounted
onErrorCapturederrorCaptured
onActivatedactivated
onDeactivateddeactivated

4、实际应用示例

<template>
  <div>
    <h2>生命周期示例</h2>
    <p>计数: {{ count }}</p>
    <button @click="count++">增加</button>
  </div>
</template>

<script setup>
import { 
  ref, 
  onBeforeMount, 
  onMounted,
  onBeforeUpdate,
  onUpdated,
  onBeforeUnmount,
  onUnmounted
} from 'vue'

const count = ref(0)

onBeforeMount(() => {
  console.log('1. 组件即将挂载 - count:', count.value)
})

onMounted(() => {
  console.log('2. 组件已挂载 - 可以访问DOM')
  // 这里可以执行需要DOM的操作
})

onBeforeUpdate(() => {
  console.log('3. 组件即将更新 - 旧count:', count.value)
})

onUpdated(() => {
  console.log('4. 组件已更新 - 新count:', count.value)
})

onBeforeUnmount(() => {
  console.log('5. 组件即将卸载')
})

onUnmounted(() => {
  console.log('6. 组件已卸载')
  // 清理工作
})
</script>

5、最佳实践

  • ​​逻辑组织​​:将相关生命周期逻辑放在一起,保持代码可读性;
  • ​​清理工作​​:在onUnmounted中清理定时器、事件监听等资源;
  • ​​避免滥用​​:不是所有逻辑都需要放在生命周期中,有些可以放在方法中按需调用;
  • ​​异步操作​​:在onMounted中进行DOM操作或数据获取;
  • 性能优化​​:使用onRenderTracked和onRenderTriggered调试性能问题;

九、组合式API - 父子通信

1、父传子 - Props
父组件传递props:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent 
    :title="pageTitle" 
    :count="counter" 
    :user="userData"
  />
</template>

<script setup>
import { ref, reactive } from 'vue'
import ChildComponent from './ChildComponent.vue'

const pageTitle = ref('Vue 3父子通信')
const counter = ref(0)
const userData = reactive({
  name: '张三',
  age: 25
})
</script>

子组件接收props:

<!-- ChildComponent.vue -->
<template>
  <div>
    <h2>{{ title }}</h2>
    <p>计数: {{ count }}</p>
    <p>用户: {{ user.name }} - {{ user.age }}岁</p>
  </div>
</template>

<script setup>
// 定义props
const props = defineProps({
  title: {
    type: String,
    required: true
  },
  count: {
    type: Number,
    default: 0
  },
  user: {
    type: Object,
    default: () => ({})
  }
})
</script>

2、子传父 - Emits
子组件触发事件:

<!-- ChildComponent.vue -->
<template>
  <button @click="increment">增加计数</button>
  <button @click="sendData">发送数据</button>
</template>

<script setup>
// 定义emits
const emit = defineEmits(['increment', 'submit-data'])

const increment = () => {
  emit('increment')
}

const sendData = () => {
  emit('submit-data', {
    message: '来自子组件的数据',
    timestamp: new Date()
  })
}
</script>

父组件监听事件:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent 
    @increment="handleIncrement"
    @submit-data="handleData"
  />
</template>

<script setup>
import ChildComponent from './ChildComponent.vue'

const handleIncrement = () => {
  console.log('子组件触发了increment事件')
}

const handleData = (data) => {
  console.log('接收到子组件数据:', data)
}
</script>

3、使用v-model实现双向绑定
Vue 3支持多个v-model绑定:
子组件:

<!-- ChildComponent.vue -->
<template>
  <input 
    :value="modelValue" 
    @input="$emit('update:modelValue', $event.target.value)"
  />
</template>

<script setup>
defineProps(['modelValue'])
defineEmits(['update:modelValue'])
</script>

父组件:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent v-model="message" />
  <!-- 相当于 -->
  <!-- <ChildComponent :modelValue="message" @update:modelValue="message" /> -->
  <p>父组件中的消息: {{ message }}</p>
</template>

<script setup>
import { ref } from 'vue'
import ChildComponent from './ChildComponent.vue'

const message = ref('')
</script>

4、使用插槽(Slot)通信
默认插槽:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent>
    <p>这是插入到子组件的内容</p>
  </ChildComponent>
</template>

<!-- ChildComponent.vue -->
<template>
  <div>
    <h2>子组件标题</h2>
    <slot></slot> <!-- 插槽内容将在这里渲染 -->
  </div>
</template>

具名插槽:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent>
    <template #header>
      <h1>自定义标题</h1>
    </template>
    <template #footer>
      <p>自定义页脚</p>
    </template>
  </ChildComponent>
</template>

<!-- ChildComponent.vue -->
<template>
  <div>
    <slot name="header"></slot>
    <div>子组件内容</div>
    <slot name="footer"></slot>
  </div>
</template>

作用域插槽:

<!-- ParentComponent.vue -->
<template>
  <ChildComponent v-slot="slotProps">
    <p>来自子组件的数据: {{ slotProps.userData }}</p>
  </ChildComponent>
</template>

<!-- ChildComponent.vue -->
<template>
  <div>
    <slot :userData="user"></slot>
  </div>
</template>

<script setup>
import { reactive } from 'vue'

const user = reactive({
  name: '李四',
  age: 30
})
</script>

5、使用provide/inject跨层级通信
祖先组件提供数据:

<!-- AncestorComponent.vue -->
<template>
  <ParentComponent />
</template>

<script setup>
import { provide, ref } from 'vue'
import ParentComponent from './ParentComponent.vue'

const theme = ref('dark')

// 提供数据
provide('theme', theme)
provide('appName', 'Vue 3应用')
</script>

后代组件注入数据:

<!-- DescendantComponent.vue -->
<template>
  <div :class="theme">
    <h2>{{ appName }}</h2>
  </div>
</template>

<script setup>
import { inject } from 'vue'

// 注入数据
const theme = inject('theme', 'light') // 第二个参数是默认值
const appName = inject('appName')
</script>

还可以传递方法;
祖先组件提供方法:

<!-- AncestorComponent.vue -->
<template>
  <ParentComponent />
</template>

<script setup>
import { provide } from 'vue'
import ParentComponent from './ParentComponent.vue'

// 提供方法
const showNotification = (message) => {
  alert(`通知: ${message}`)
}

const updateTheme = (newTheme) => {
  console.log('主题更新为:', newTheme)
}

provide('showNotification', showNotification)
provide('updateTheme', updateTheme)
</script>

后代组件使用方法:

<!-- DescendantComponent.vue -->
<template>
  <button @click="notify">显示通知</button>
  <button @click="changeTheme">切换主题</button>
</template>

<script setup>
import { inject } from 'vue'

// 注入方法
const showNotification = inject('showNotification')
const updateTheme = inject('updateTheme')

const notify = () => {
  showNotification('这是来自子组件的消息')
}

const changeTheme = () => {
  updateTheme('dark')
}
</script>

6、使用ref访问子组件

<!-- ParentComponent.vue -->
<template>
  <ChildComponent ref="childRef" />
  <button @click="callChildMethod">调用子组件方法</button>
</template>

<script setup>
import { ref } from 'vue'
import ChildComponent from './ChildComponent.vue'

const childRef = ref(null)

const callChildMethod = () => {
  if (childRef.value) {
    childRef.value.sayHello()
  }
}
</script>

<!-- ChildComponent.vue -->
<script setup>
const sayHello = () => {
  console.log('Hello from child component!')
}

// 暴露方法给父组件
defineExpose({
  sayHello
})
</script>

defineExpose:

  • 默认情况下在 <script setup>语法糖下组件内部的属性和方法是不开放给父组件访问的,可以通过defineExpose编译宏指定哪些属性和方法容许访问;

7、最佳实践

  • ​​props向下​​:数据流应该主要从父组件流向子组件;
  • ​​events向上​​:子组件应该通过事件通知父组件状态变化;
  • ​​避免直接修改props​​:子组件不应该直接修改props,应该通过emit事件让父组件修改;
  • ​​合理使用provide/inject​​:适用于跨多层级的通信,但不应该滥用;
  • 谨慎使用ref访问子组件​​:这会增加组件间的耦合度;
  • ​​类型安全​​:使用TypeScript时,为props和emits定义明确的类型;

十、Vue3.3 新特性

1、defineOptions
Vue 3.3 引入了 defineOptions 宏,这是一个在 <script setup> 中定义组件选项的新方式,解决了之前无法直接在 <script setup> 中声明组件选项(如 name、inheritAttrs 等)的问题。

<script setup>
import { defineOptions } from 'vue'

defineOptions({
  name: 'MyComponent',
  inheritAttrs: false
})
</script>

2、defineModel
Vue 3.3 引入了 defineModel 宏,这是一个简化组件双向绑定的新特性,特别针对 v-model 的使用场景进行了优化。

<!-- ChildComponent.vue -->
<script setup>
const model = defineModel()
</script>

<template>
  <input v-model="model">
</template>

<!-- ParentComponent.vue -->
<template>
  <ChildComponent v-model="message" />
</template>

<script setup>
import { ref } from 'vue'
const message = ref('')
</script>

十一、Vue3 Pinia的使用

Pinia 是 Vue 3 的官方推荐状态管理库,相比 Vuex 更简单、更符合组合式 API 的设计理念。
1、安装 Pinia

npm install pinia
# 或
yarn add pinia

2、创建 Pinia 实例并注册

// main.js
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'

const pinia = createPinia()
const app = createApp(App)

app.use(pinia)
app.mount('#app')

3、定义 Store

// stores/counter.js
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0,
    name: 'Eduardo'
  }),
  getters: {
    doubleCount: (state) => state.count * 2,
    doubleCountPlusOne() {
      return this.doubleCount + 1
    }
  },
  actions: {
    increment() {
      this.count++
    },
    async incrementAsync() {
      await new Promise(resolve => setTimeout(resolve, 1000))
      this.increment()
    }
  }
})

Pinia 也支持组合式 API 风格的 Store 定义:

// stores/counter.js
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore('counter', () => {
  // state
  const count = ref(0)
  const name = ref('Eduardo')

  // getters (使用 computed)
  const doubleCount = computed(() => count.value * 2)
  const doubleCountPlusOne = computed(() => doubleCount.value + 1)

  // actions (普通函数)
  function increment() {
    count.value++
  }

  async function incrementAsync() {
    await new Promise(resolve => setTimeout(resolve, 1000))
    increment()
  }

  return {
    // state
    count,name,
    
    // getters
    doubleCount,doubleCountPlusOne,
    
    // actions
    increment,incrementAsync
  }
})

4、在组件中使用 Store

<script setup>
import { useCounterStore } from '@/stores/counter'

const counter = useCounterStore()

// 直接访问 state
console.log(counter.count) // 0

// 调用 action
counter.increment()

// 使用 getter
console.log(counter.doubleCount) // 2
</script>

<template>
  <div>
    <h1>{{ counter.count }}</h1>
    <button @click="counter.increment()">Increment</button>
    <p>Double count: {{ counter.doubleCount }}</p>
  </div>
</template>

5、状态持久化
可以使用 pinia-plugin-persistedstate 插件实现状态持久化:

npm install pinia-plugin-persistedstate
// main.js
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

然后在 Store 中启用:

export const useCounterStore = defineStore('counter', {
  // ...其他配置
  persist: true
})

在选项式 API 中使用:

import { mapState, mapActions } from 'pinia'
import { useCounterStore } from '@/stores/counter'

export default {
  computed: {
    ...mapState(useCounterStore, ['count', 'doubleCount'])
  },
  methods: {
    ...mapActions(useCounterStore, ['increment'])
  }
}

在组合式API中使用:

<script setup>
import { useCounterStore } from '@/stores/counter'

const counter = useCounterStore()

// 直接访问 state 和 getters
const count = computed(() => counter.count)
const doubleCount = computed(() => counter.doubleCount)

// 直接调用 actions
function increment() {
  counter.increment()
}
</script>

<template>
  <!-- 模板中使用方式不变 -->
  <div>{{ count }}</div>
  <div>{{ doubleCount }}</div>
  <button @click="increment">Increment</button>
</template>

6、Pinia 的主要优势

  • 更简单的 API 设计;
  • 完美的 TypeScript 支持;
  • 支持组合式 API;
  • 模块化设计,无需嵌套模块;
  • 更轻量级;
前端面经-VUE3篇(一)--vue3基础知识- 插值表达式、ref、reactive 在 Vue 中,指令(Directives)是带有前缀v-的特殊属性,用于在模板中提供特定的行为或功能。Vue 的指令本质上是一种模板语法扩展。用来在模板中声明式地控制 DOM 的行为、渲染逻辑以及响应式交互。当内置指令不能满足需求时,用户可以创建自定义指令。注册示例(Vue 3.x)el.focus()})指令的生命周期钩子(自定义指令专用)钩子函数描述created指令绑定元素后调用元素插入到 DOM 前调用mounted元素插入到 DOM 后调用更新前调用updated更新后调用。 阅读详情

相关推荐

Vue 核心知识点总结

本文系统梳理了Vue框架的核心面试知识点,重点对比了Vue3与Vue2的差异,包括Composition API、Proxy响应式系统等新特性。详细解析了组件通信方式、生命周期变化、v-if与v-show区别等关键概念,并给出性能优化建议。同时比较了Vuex与Pinia的状态管理方案,最后介绍了Vue-router导航守卫的应用场景。帮助开发者全面掌握Vue技术栈,为面试做好充分准备。

赵得C 1128

Vue3知识点(尚硅谷张天禹)

Vue3.0基础知识

weixin_48240707的博客 4452

论文阅读4——一种宽频带圆极化微带天线的设计

论文阅读——一种宽频带圆极化微带天线的设计(现在才觉得开始弄懂了一点,懂了一点之后又更糊涂了……)

weixin_64612422的博客 2317

Vue3常用知识点总结

Vue.js 3.0 "One Piece" 正式版在今年9月份发布2年多开发, 100+位贡献者, 2600+次提交, 600+次PRVue3支持vue2的大多数特性更好的支持Typescript使用Vue3的组合API封装的可复用的功能函数自定义hook的作用类似于vue2中的mixin技术自定义Hook的优势: 很清楚复用功能代码的来源, 更清楚易懂//需求1: 收集用户鼠标点击的页面坐标hooks/useMousePosition.ts/*收集用户鼠标点击的页面坐标*/

Ssss555123的博客 3631

飞牛Docker部署Zerotier后无法访问?三步搞定SSH权限配置!

本文详细解析了在飞牛NAS上通过Docker部署Zerotier后无法访问的常见问题及解决方案。重点介绍了SSH权限配置、tun模块加载和Docker容器权限设置等关键步骤,帮助用户快速解决虚拟网络接口的权限问题,确保Zerotier节点间的正常通信。

qq_27496129的博客 792

VisionMaster位置修正功能深度解析:如何让找圆工具自动跟随移动目标?

本文深度解析海康威视VisionMaster平台的位置修正功能,重点介绍如何通过模板匹配与找圆工具的智能联动实现移动目标的动态追踪。文章详细阐述了工业视觉检测中的坐标系同步原理、模板匹配配置技巧及异常处理策略,为工程师提供了一套完整的工业级解决方案。

uu89012的博客 281

VUE3基础知识梳理

VUE3基础知识梳理一、vue了解和环境搭建1.vue是什么:cn.vuejs.org/vuejs.org2.渐进式框架3.vue的版本4.vueAPI的风格5.准备环境5.1.创建vue项目5.2.vue的目录结构二、vue3语法1.干净的vue项目2.模板语法2.1 文本插值2.2属性绑定2.3条件渲染2.4列表渲染2.5通过key管理状态2.6事件处理2.7事件传参2.8事件修饰符2.9数组变化侦测2.10 计算属性2.11 class绑定2.12 style绑定2.13 侦听器2.14 表单输入绑定

初心不忘、始终方得 4332

PyMuPDF`库实现PDF旋转功能

本文介绍了一个简单的Python应用程序,用于将PDF文件转换为旋转90度的PDF文件。通过使用`wx很抱歉,Markdown格式在当前聊天界面无法显示。我将为您提供纯文本格式的博客内容,您可以将其复制到Markdown编辑器中进行格式化。PDF转换工具本文介绍了一个简单的Python应用程序,用于将PDF文件转换为旋转90度的PDF文件。该工具使用了wxPython和PyMuPDF库。功能该PDF转换工具具有以下功能:1. 选择PDF文件:通过点击“选择文件”按钮,用户可以选择要转换的PDF文件。

Winfredzhang的博客 2735

vue3常见知识点总结

vue3知识点

qq_59185329的博客 1490

别再只飞不记了!用CsvView分析你的大疆飞行日志,优化航拍与排查炸机原因

本文详细介绍了如何利用CsvView工具分析大疆无人机的飞行日志,帮助用户优化航拍效率和飞行安全。通过解读飞行日志中的关键数据,如电池性能、飞行轨迹等,用户可以及时发现潜在问题并改进飞行习惯。文章还提供了事故排查方法和进阶分析技巧,适合无人机爱好者和专业飞手。

weixin_42535461的博客 548

手把手教你搞定6脚三位一体数码管的驱动(附C语言源码与Visual Studio调试技巧)

本文详细解析了6脚三位一体数码管的驱动原理与实战技巧,包括引脚复用、动态扫描时序、Visual Studio模拟调试及单片机实现。通过C语言源码示例和调试技巧,帮助开发者快速掌握非标准数码管的驱动方法,提升硬件开发效率。

weixin_30613727的博客 591

vue3的知识点梳理

Composition API (setup):逻辑按功能聚合,复用性强,TS友好。:模板允许多根节点,不再必须一个根 div;:传送门,把模板 DOM 渲染到组件 DOM 树之外(body 下,弹窗、浮层):处理异步组件,等待异步组件加载,显示 fallback 占位。options API:选项式,代码分散,大型项目难维护。toRefs:批量解构对象所有属性,解构后不丢失响应式。toRef:单独提取对象一个属性,保持响应式。markRaw:标记对象,永远不做响应式代理。

weixin_47151361的博客 175

LeRobot 入门教程(七)数据集

LeRobot Dataset v3.0 是机器人学习数据的标准化格式,支持多模态时间序列数据和视频的统一访问。该版本通过基于文件的存储(Parquet/MP4)、关联元数据和Hub原生流式处理等新特性,显著提升了性能并降低了存储开销。文档详细介绍了格式设计、安装使用、数据记录与加载方法,以及从v2.1迁移到v3.0的步骤,特别针对大型数据集(如DROID 1.0.1)的处理提供了SLURM集群移植方案。v3.0通过优化文件组织和元数据管理,实现了更快的加载速度、更高的内存效率和更好的可扩展性。

2506_90492529的博客 2054

vue3常用知识点梳理

6,计算属性与监视属性1,setupvue3中一个新的配置项,值为函数。组件中所用到的数据,方法,生命周期,监视属性,计算属性等都要配置在setup中。setup函数的两种返回值1,若返回一个对象,则对象中的属性、方法, 在模板中均可以直接使用。2,若返回一个渲染函数:则可以自定义渲染内容。1,尽量不要与Vue2.x配置混用2,setup不能是一个async函数,因为返回值不再是return的对象, 而是promise, 模板看不到return对象中的属性。

君子-如兰的博客 1731

【推荐100个unity插件】帮助你快速开发一款FPS游戏—— FPS Framework

FPS Framework 快速入门指南 FPS Framework 是一个 Unity 开发框架,可加速 FPS 游戏开发。主要功能包括: 第一人称控制器:基于 Character Controller 实现,提供移动、跳跃、下蹲等功能,支持自定义参数调整 渲染管线转换:内置 RP 转换器,支持 URP/HDRP 等渲染管线一键切换 库存系统: 采用双列表管理:物品列表(Items)和可收集物列表(Collectables) 支持自定义库存物品和可收集物类型 提供拾取/丢弃功能实现 快速开始: 通过预制件

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 2569

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Vue3.0知识点梳理

Vue3学习知识点vue3安装创建vue3父子组件传值vue3ref的理解vue3路由创建-跳转-传值-获取vue3在原型中挂载方法及使用vue3computed的使用如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 vue3安装创建 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果

Monster_X的博客 1066

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Vue3前端面试核心知识点梳理

本文全面梳理了Vue3生态中的核心知识点,包括: Composition API:Vue3引入的代码组织方式,通过<script setup>语法糖实现逻辑聚合,解决了Options API逻辑分散、复用困难等问题,支持更好的TypeScript和Tree-shaking。 Pinia状态管理:Vue3官方状态管理库,简化了Vuex的使用,提供state、getters和actions三大核心概念,适合跨组件/页面共享数据。 Vue Router优化:包括路由懒加载减少首屏体积,全局守卫实现登录鉴权和取消残

2501_92559307的博客 285

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

vue3.0知识点梳理

vue3在原型中挂载方法及使用前言使用步骤 前言 vue3不像vue2一样可以有this操作,那么如果往原型上做一番操作,该怎么操作操作? 提示:以下是本篇文章正文内容,下面案例可供参考 使用步骤 main.js代码如下(示例): import { createApp } from 'vue' import App from './App.vue' import router from './router' import { CP } from 'wheels/dist/wheel.min.js' con

Monster_X的博客 571

WHAT - Vue3 重要知识点梳理系列(二)

本系列旨在帮助开发者深入了解 Vue 3 的重点知识点。无论是初学者还是有经验的开发者,都可以从本系列中查缺补漏,获取的新的认识,提升对 Vue 3 的理解和应用能力。

weixin_58540586的博客 1550

WHAT - Vue3 重要知识点梳理系列(一)

本系列旨在帮助开发者深入了解 Vue 3 的重点知识点。无论是初学者还是有经验的开发者,都可以从本系列中查缺补漏,获取的新的认识,提升对 Vue 3 的理解和应用能力。

weixin_58540586的博客 1148

uniapp vue3 常用知识点梳理-快速上手篇

本文系统介绍了uni-app+Vue3项目的三类生命周期:1. 应用生命周期(App.vue):核心钩子onLaunch和onShow用于全局初始化及前后台状态管理 2. 页面生命周期(pages目录):关键钩子onLoad、onShow、onReady处理页面加载/显示/渲染逻辑 3. 组件生命周期(components目录):Vue3原生钩子onMounted、onBeforeUnmount等控制组件挂载与销毁 文中通过典型代码示例说明各生命周期执行时机和用途,并总结了页面加载时的完整触发顺序,帮助开发

JackieDYH的博客 634

vue3+ts+vite项目开发--知识点梳理01

vue3+ts+vite项目开发--知识点梳理01

joan_yb的博客 1036

Vue3 项目开发常用知识点梳理

watch也能计算属性,能监听对象里属性的变化,立即监听加{immediate:true},深度监听加{deep: true},可以异步响应,没有返回值。computed 一般用来获取实时更新的缓存内容,如cookies,session,vuex里面的内容,具体的:用户姓名,昵称,根据不同权限判断初始化加载数据大小。基本上能用computed的,watch也能用,但是有的情况,只能用computed,而有的情况需要用watch。2:当前的组件属性向上抛,父组件通过ref获取当前的属性,再传递到兄弟组件。

qq_40505914的博客 168

「offer来了」从基础到进阶原理,从vue2到vue3,48个知识点保姆级带你巩固vuejs知识体系

巩固你的vuejs知识体系序言一、vue2.x基础知识预备二、vue2.x基础知识常见面试题1. 请说出vue.cli项目中src目录每个文件夹和文件的用法?2. vue.cli中怎样使用自定义的组件?有遇到过哪些问题?3. v-show和v-if的区别4. 为何v-for中要用key5. 描述Vue组件生命周期(1)单组件生命周期(2)父子组件生命周期关系6. Vue组件如何通讯(常见)7. 描述组件渲染和更新的过程8. vue如何处理刷新数据不丢失9. 双向数据绑定 v-mo

moandaylab 4923

Vue框架核心知识点快速梳理与实战指南

建议从平台提供的"Vue3入门示例"开始,逐步尝试添加路由、状态管理等模块,这种即时反馈的学习方式能有效巩固知识点。对于需要演示的组件案例,平台的一键部署功能可以直接生成可分享的在线demo,方便教学和交流。可以快速体验Vue项目创建和部署,平台内置的Vue模板和实时预览功能特别适合初学者验证各种语法特性。我在使用过程中发现其环境配置非常省心,一键生成的项目直接包含Vue3全家桶配置,省去了手动搭建的麻烦。| 特性 | Vuex | Pinia |

JetFalcon67的博客 427

vue2.0和vue3.0中的区别

一、mian.js中vue的实例化 main.js入口文件 :初始化实例使用的插件(css、router、store),将内容渲染到页面上,项目文件的入口,执行js的时机是从main.js从上到下的执行的 vue2 import Vue from 'vue' import App from './App' import router from './router' new Vue({ el: '#app', router, render: h => h(App) }) vue3

^_^ 1664
上一篇: JavaScript判断数据的类型
下一篇: JavaScript 加减运算精度损失问题解决
testleaf
博客等级 码龄7年 3514粉丝 72原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

testleaf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值