vue3.0 語法糖 script 標簽里面添加 setup


vue3.0 使用setup 語法糖

使用 props

import { defineProps} from 'vue'
const props = defineProps({
  total: {
    type: Number,
    default: 0
  },
  page: {
    type: Number,
    default: 2
  }
})

使用 emit

<script setup>
import { defineEmits } from 'vue'
const emit = defineEmits(['update:page'])
</script>

使用 attr

<script setup>
import { useAttrs} from 'vue'
const attrs = useAttrs()
</script>

使用 Slot

<script setup>
import { useSlots} from 'vue'
const slots = useSlots()
</script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM