How to import the Vue2Vis library?

0

I was trying to create a TimeLine using Vis.js, using the Vuejs 2 adapter for Visjs, ( link ) and the following error:

It should be some import error. If someone can help, follow the code:

import vue2vis from 'vue2vis';
import Vue from 'vue'
Vue.component('timeline', vue2vis.Timeline);
const ItemComponent = Vue.extend({
    template: '<p>{{item.content}}</p>',
    props: ['item'],
});
export default {
    data(){
        return {
            groups: [{
                id: 0,
                content: 'Group 1'
            }],
            items: [{
                id: 0,
                group: 0,
                start: new Date(),
                content: 'Item 1'
            }],
            options: {
                editable: true,
                template: (item) => {
                    return new ItemComponent({
                        store: this.$store,
                        parent: this,
                        propsData: {
                            item,
                        },
                    }).$mount().$el;
                }
            }
        }
    },
}  
<div id="visualization" ref="myDiv">
    <timeline ref="timeline" :items="items" :groups="groups" :options="options">
    </div>
</div>

Thanks in advance for your help!

    
asked by anonymous 17.01.2018 / 01:54

1 answer

0

I'm new to using vue2vis, but with version 0.0.15 I did not have to import Vue or vue2vis:

<script>
import { Timeline } from 'vue2vis';

export default {
    ...
}
</script>

See the full example here .

If you have an error with vue2vis.css , use

@import '~vue2vis/dist/vue2vis.css'

instead of

@import 'vue2vis/dist/vue2vis.css''
    
21.08.2018 / 22:21