vue3.0 + el-table


 

1、template:

<el-table :data="state.weather">
  <el-table-column prop="id" label="日期" width="180"></el-table-column>
  <el-table-column prop="username" label="姓名" width="200"></el-table-column>
  <el-table-column prop="memberName" label="地址"></el-table-column>
</el-table>

2、script:

    import { defineComponent, onMounted, onUnmounted, ref, reactive } from 'vue'
    import axios from "axios";
    export default defineComponent ({
        name: 'Home',
        setup() {const state = reactive({}); // 定義數據
       
async function fetchData() { axios.post("/goods/goodall2").then((res)=>{ // 自定義mock數據 state.weather = res.data.data; // 賦值 console.log(state.weather); }).catch(function (error) {}); }
       // 頁面加載時候執行
onMounted(() => { state.value = fetchData(); }); return { state, // table數組return }; } })

 

詳細的安裝 mock 看:https://www.cnblogs.com/moguzi12345/p/14524580.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM