为了账号安全,请及时绑定邮箱和手机立即绑定

【金秋打卡】第16天 数据报表项目初始化

标签:
职场生活

课程名称:Vue + EChart 4.0 从0到1打造商业级数据报表项目

课程章节数据报表项目初始化
课程讲师: Sam

课程内容:

数据报表项目介绍

1、技术选型

2、前端静态页面开发


项目初始化
项目初始化

安装vue脚手架:cnpm i -g @vue/cli

vue create imooc-datev-report // 创建项目选择manually手动安装 安装下babel router css pre-processours linter / fotmatter

不选择history模式:? use history mode for router? (Requirestup for index fallback in production) No

选择sass/scss css预处理 第二个

保存时做lint检查:Pick additional lint features :Lint on save

babel等保存到特定的文件中,方便以后管理使用

运行项目:npm run serve

删除无关的页面开始做项目开发

如何引入element-ui echart
vue add element

选择按需引入,减少打包的体积

选择需要加载的文字:zh-CN 中文

.eslintrc.js 关闭缩进

安装echarts

cnpm i -S echarts

然后在main.js中引入


容器初始化

<template>
  <div class="home">
    <top-view />
    <sales-view />
    <bottom-view />
    <map-view />
  </div>
</template>

<script>
  import TopView from '../components/TopView'
  import SalesView from '../components/SalesView'
  import BottomView from '../components/BottomView'
  import MapView from '../components/MapView'
  import { wordcloud, screenData, mapScatter } from '../api'

  export default {
    name: 'Home',
    components: {
      TopView,
      SalesView,
      BottomView,
      MapView
    },
    data() {
      return {
        reportData: null,
        wordCloud: null,
        mapData: null
      }
    },
    methods: {
      getReportData() {
        return this.reportData
      },
      getWordCloud() {
        return this.wordCloud
      },
      getMapData() {
        return this.mapData
      }
    },
    provide() {
      return {
        getReportData: this.getReportData,
        getWordCloud: this.getWordCloud,
        getMapData: this.getMapData
      }
    },
    mounted() {
      screenData().then(data => { this.reportData = data })
      wordcloud().then(data => { this.wordCloud = data })
      mapScatter().then(data => { this.mapData = data })
    }
  }
</script>

<style>
  .home {
    width: 100%;
    padding: 20px;
    background: #eee;
    box-sizing: border-box;
  }
</style>

顶部核心指标组件布局开发
plugins / element 引入Card ,Row 、Col 分别设置卡片/行/列


import { Card, Row, Col } from 'element-ui'

Vue.use(Card)
Vue.use(Row)
Vue.use(Col)

components / TopView 在topview中添加四个卡片,

 // el-row :gutter 栅格间隔
 //el-col :span 栅格所占列数
	<template>
  <div class="top-view">
    <el-row :gutter="20">
      <el-col :span="6">
        <el-card shadow="hover">
         
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
          
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
          
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="hover">
         
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>


  export default {

  }
</script>

<style lang="scss" scoped>
</style>

课程收获:
初始化项目,选择vue2,babel 、router 删除自动沟通的多余的代码,并添加element-ui echarts,然后初始化topview项目,建立四个卡片,设置它的样式,学习到了怎么设置element的初始化,按需加载,尽量的减少包的体积等

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
Web前端工程师
手记
粉丝
2
获赞与收藏
23

关注作者,订阅最新文章

阅读免费教程

  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消