<template>
  <div class="page">
    page is search
    <ul>
      <li v-for="(item,idx) in list" :key="idx">{{item}}</li>
    </ul>
  </div>
</template>
<script>
import axios from 'axios';
export default {
  layout: 'search',
  data() {
    return {
      list: []
    }
  },
  async asyncData(){
    let { status, data: {list}} = await axios.get('http://localhost:3000/city/list')
    if(status === 200){
        return {
            list
        }
    }
  }
}
</script>
<style scoped>
</style>

使用asyncData就是服务端渲染,computed只是浏览器的渲染刷新会有闪烁

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2020-01-02
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2021-12-15
  • 2021-07-18
  • 2021-09-03
  • 2021-11-08
  • 2021-12-07
相关资源
相似解决方案