zoukankan      html  css  js  c++  java
  • 单页面中使用vue和iview、echarts,引用组件

    index.html文件

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>单页面应用</title>
        <link rel="stylesheet" href="//unpkg.com/iview/dist/styles/iview.css">
        <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
        <script src="https://unpkg.com/http-vue-loader"></script>
        <script src="//unpkg.com/iview/dist/iview.min.js"></script>
        <script src="js/echarts.js"></script>
    </head>
    <body>
    <div id="app">
        <headers></headers>
        <hr/>
        <echarts></echarts>
    </div>
    <script>
        // 使用httpVueLoader
        Vue.use(httpVueLoader);
        new Vue({
            el: '#app',
            data: {
               
            },
            components:{
                "headers":"url:./components/headers.vue",
                "echarts":"url:./components/echarts.vue"
            },
            methods: {
                
            },
            mounted() {
            }
        })
    </script>
    <style>
        html,body,#app{
             100%;
            height: 100%;
            background-color:#f5f5f5;
        }
    </style>
    </body>
    </html>

    headers.vue

    <template>
      <div>
            <i-button>Default</i-button>
            <i-button type="primary">Primary</i-button>
            <i-button type="dashed">Dashed</i-button>
            <i-button type="text">Text</i-button>
            <br><br>
            <i-button type="info">信息按钮</i-button>
            <i-button type="success">成功按钮</i-button>
            <i-button type="warning">警告按钮</i-button>
            <i-button type="error">错误按钮</i-button>
            <i-button>Click me!</i-button>
      </div>
    </template>
    
    <script>
    module.exports =  {
    
    }
    </script>
    
    <style>
    
    </style>

    echarts.vue

    <template>
      <div>
        <div style="500px;height:500px" ref="chart"></div>
      </div>
    </template>
    <script>
      const echarts = require('echarts');
      module.exports = {
        data () {
          return {};
        },
        methods: {
          initCharts () {
            let myChart = echarts.init(this.$refs.chart);
            // 绘制图表
            myChart.setOption({
                title: { text: '在Vue中使用echarts' },
                tooltip: {},
                xAxis: {
                    data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
                },
                yAxis: {},
                series: [{
                    name: '销量',
                    type: 'bar',
                    data: [5, 20, 36, 10, 10, 20]
                }]
            });
          }
        },
        mounted () {
          this.initCharts();
        }
      }
    </script>

    echarts.js

    echarts官网下个echarts.js即可

  • 相关阅读:
    子查询
    多表连接
    类型转换和其他函数
    亲测!Jquery2.0不支持IE8-了
    Sass结合Modernizr的使用方法
    子元素绝对定位撑不开父元素的解决方法
    ajax withCredentials在firefox下问题的解释
    记录遇到的IE8兼容性问题汇总
    对于requirejs AMD模块加载的理解
    requirejs 小结
  • 原文地址:https://www.cnblogs.com/zhangkeke/p/15597864.html
Copyright © 2011-2022 走看看