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