vue3使用computed,如下代码块:
<template>
<div>
{{showTypeBy}}
</div>
</template>
<script>
import { reactive, toRefs, computed, onMounted } from 'vue'
export default {
name: 'demandTypePicker',
props: ['showType'],
setup (props, { emit }) {
const state = reactive({
})
onMounted(() => {
})
const showTypeBy = computed({
get () {
return props.showType
},
set () {
return props.showType
}
})
return {
...toRefs(state),
showTypeBy
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>