计算属性
<script setup>
import { ref, computed } from 'vue'
const arr = ref(['a', 'b', 'c', 'd'])
const coArr = computed(() => {
return arr.value.join(',')
})
// js中引用计算属性需要加.value
console.log(coArr.value) // 输出:"a,b,c,d"
</script>
计算属性
<script setup>
import { ref, computed } from 'vue'
const arr = ref(['a', 'b', 'c', 'd'])
const coArr = computed(() => {
return arr.value.join(',')
})
// js中引用计算属性需要加.value
console.log(coArr.value) // 输出:"a,b,c,d"
</script>