Vue3踩坑記錄-持續更新

使用Vue3可能踩的坑,本文只是使用了@vue/composition-api 而不是使用alpha版本的Vue3

v-on陷阱

<div @click="alert(1)"></div>

這句話是會報錯的 說找不到alert

爲什麼,Vue3 的模板只關注setup返回值,setup連this都沒有,何況window更是不可能直接暴露

還是乖乖地寫方法吧

修改後
<template>
  <div @click="alert(1)"></div>
</template>
<script lang="ts">
import { defineComponent, ref, reactive } from "@vue/composition-api";
export default defineComponent({
  name: "Alert",
  setup() {
    return {
      alert:(num)=> alert(num)
    }
  }
});
</script>

lastupdate: 20200227

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章