阿里云dataV大屏可视化的使用攻略——vue项目

好好学习 ,天天向上。Are you ready?在这里插入图片描述

代码奉上!!!!!!!!!

首先登陆阿里云控制台,创建应用
在这里插入图片描述
选模板,创建名称
在这里插入图片描述
通过编辑预览项目
在这里插入图片描述
在这里插入图片描述

发布大屏在这里插入图片描述发布成功,可以去直接访问网址,通过vue项目内嵌iframe 来实现dataV的引用

demo1 vue代码示例 (此处为未设置Token验证)

在这里插入图片描述

<template>
  <div class="block">
    <iframe
      :width="searchTableWidth"
      :height="searchTableHeight"
      :src="reportUrl"
      style="border:none"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      reportUrl: '',
      searchTableHeight: 0,
      searchTableWidth: 0
    }
  },
  watch: {
    '$route': function() {
      // 监听路由变化
      this.reportUrl = this.$route.meta.pathUrl
    }
  },
  created() {
   this.reportUrl = 'http://datav.aliyun.com/share8888888888888888888888'
  },
  mounted() {
    window.onresize = () => {
      this.widthHeight() // 自适应高宽度
    }
    this.$nextTick(function() {
      this.widthHeight()
    })
  },
  methods: {
    widthHeight() {
      this.searchTableHeight = window.innerHeight + 'px'
      this.searchTableWidth = window.innerWidth + 'px'
    }
  }
}
</script>
<style lang="scss" scoped>
</style>

demo2 vue代码示例 (此处为设置Token验证)

在这里插入图片描述

<template>
  <div class="block">
    <iframe
      :width="searchTableWidth"
      :height="searchTableHeight"
      :src="reportUrl"
      style="border:none"
    />
  </div>
</template>

<script>
const crypto = require('crypto')
export default {
  data() {
    return {
      reportUrl: '',
      searchTableHeight: 0,
      searchTableWidth: 0
    }
  },
  watch: {
    '$route': function() {
      // 监听路由变化
      this.reportUrl = this.$route.meta.pathUrl
    }
  },
  created() {
    var token = 'lKqT2q6h5ME0bo99999999999'
    var screenID = '09e1538779103777777777777777'
    var time = Date.now()
    var stringToSign = screenID + '|' + time
    console.log(token, stringToSign)
    var signature = crypto.createHmac('sha256', token).update(stringToSign).digest().toString('base64')
    this.reportUrl = 'http://datav.aliyun.com/share/' + screenID + '?_datav_time=' + time + '&_datav_signature=' + encodeURIComponent(signature)
  },
  mounted() {
    window.onresize = () => {
      this.widthHeight() // 自适应高宽度
    }
    this.$nextTick(function() {
      this.widthHeight()
    })
  },
  methods: {
    widthHeight() {
      this.searchTableHeight = window.innerHeight + 'px'
      this.searchTableWidth = window.innerWidth + 'px'
    }
  }
}
</script>
<style lang="scss" scoped>
</style>


  • 1
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
对于使用Vue来实现DataV可视化大屏,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Vue CLI,如果没有安装,可以通过以下命令进行安装: ``` npm install -g @vue/cli ``` 2. 创建一个新的Vue项目,可以使用以下命令: ``` vue create datav-visualization ``` 3. 进入到项目目录中: ``` cd datav-visualization ``` 4. 安装DataV可视化库,可以使用以下命令: ``` npm install @jiaminghi/data-view ``` 5. 在项目中引入DataV可视化组件。你可以在`main.js`文件中添加以下代码: ```javascript import Vue from 'vue'; import App from './App.vue'; import DataV from '@jiaminghi/data-view'; Vue.use(DataV); new Vue({ render: (h) => h(App), }).$mount('#app'); ``` 6. 创建一个新的组件用于展示DataV可视化大屏。你可以在`src/components`目录下创建一个新的组件文件,例如`DataVScreen.vue`,然后在该文件中编写DataV可视化大屏代码。 7. 在需要展示DataV可视化大屏的地方使用该组件。例如,在`App.vue`文件中添加以下代码: ```vue <template> <div id="app"> <DataVScreen /> </div> </template> <script> import DataVScreen from './components/DataVScreen.vue'; export default { name: 'App', components: { DataVScreen, }, }; </script> ``` 8. 运行项目,可以使用以下命令启动开发服务器: ``` npm run serve ``` 这样,你就可以使用Vue来实现DataV可视化大屏了。当然,具体的可视化效果和功能需要根据你的需求进行定制和开发。希望对你有所帮助!如果有任何问题,请随时提问。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值