# 前言

  • 记录 Vue3 + Vite + Ts + Pinia 相关开发环境配置,方便日后查找

# Vue3 绑定动态事件

  • 一般事件绑定
<template>
  <p>count={{ count }}</p>
  <button @click="increase">count++</button>
</template>
<script setup lang="ts">
  import { ref } from 'vue';
  let count = ref<number>(0);
  const increase = () => {
    count.value++;
  }
</script>
  • 动态事件绑定
<template>
  <p>count={{ count }}</p>
  <button @[event]="increase">count++</button>
</template>
<script setup lang="ts">
  import { ref } from 'vue';
  const event='dblclick';
  let count = ref<number>(0);
  const increase = () => {
    count.value++;
  }
</script>
更新于 阅读次数