File: app/components/hackernews/userview/userview.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy  >  Hackernews Vue  >  app/components/hackernews/userview/userview.js  >  Download  
File: app/components/hackernews/userview/userview.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Hackernews Vue
View information from Hackernews using Vue.js
Author: By
Last change:
Date: 5 years ago
Size: 799 bytes
 

Contents

Class file image Download
define([
    'vue',
    'app/components/hackernews/store',
    'text!app/components/hackernews/userview/userview.html',
    'css!app/components/hackernews/userview/userview.css'
], function (Vue, store, template) {

    // Create component class
    var UserView = Vue.extend({
        name: 'userview',
        template: template,
        props: {
            comment: Object
        },
        data: function () {
            return {
                user: {}
            }
        },
        route: {
            data: function (transition) {
                return {
                    user: store.fetchUser(transition.to.params.id)
                }
            },
        }
    });

    // Create and registration component
    Vue.component('userview', UserView);

    return UserView;
});