vue3

122 阅读1分钟
<script>

import { findNew } from '@/api/home'
import { onMounted, ref } from 'vue'
export default {
  components: {
    HomePanel
  },
  setup () {
    // 1.定义响应式数据
    const list = ref([])
    // 2.定义函数 函数内部调用接口函数
    async function getList () {
      const res = await findNew()
      list.value = res.data.result
    }
    // 3. onMounted中调用getList
    onMounted(() => {
      getList()
    })
    return {
      list
    }
  }
}
</script>