一、setup函数

1.setup函数是反人类的,使用麻烦

需要先声明setup函数,再将响应式数据和方法返回,setup函数会很臃肿
image.png

2.script setup标签

(1)不用声明setup函数

(2)定义好数据和方法后,可以直接使用,不用再返回

3.vue3 script setup模板

打开file -> preference ->user snippets ->new snippets
输入模板配置jason

  1. {
  2. "Print to console": {
  3. "prefix": "vue-setup",
  4. "body": [
  5. "<template>",
  6. " <div></div>",
  7. "</template>",
  8. "<script setup></script>",
  9. "<style lang='scss' scoped>",
  10. "</style>"
  11. ],
  12. "description": "vue setup template"
  13. }
  14. }