vue3.0 语法糖 script 标签里面添加 setup

时间:2021-07-09 12:28:03   收藏:0   阅读:299

使用 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>

原文:https://www.cnblogs.com/shiazhen/p/14989345.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!