{
40 | if (this.items.length) {
41 | return;
42 | }
43 |
44 | try {
45 | const response: AxiosResponse = await this.axios.get(this.url);
46 | this.items = response.data;
47 | } catch (err) {
48 | logger.error(err);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/components/list/index.ts:
--------------------------------------------------------------------------------
1 | export * from './List';
2 |
--------------------------------------------------------------------------------
/src/components/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Id |
7 | Name |
8 | Username |
9 | Email |
10 | Address |
11 | Phone |
12 | Website |
13 | Company |
14 |
15 |
16 |
17 |
18 | {{item.id}} |
19 | {{item.name}} |
20 | {{item.username}} |
21 | {{item.email}} |
22 | {{item.address.street}}, {{item.address.suite}}, {{item.address.city}} |
23 | {{item.phone}} |
24 | {{item.website}} |
25 | {{item.company.name}} |
26 |
27 |
28 |
29 |
30 |
31 |
32 | arrow_back Home
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/components/list/types.ts:
--------------------------------------------------------------------------------
1 | export interface IUser {
2 | id: string;
3 | name: string;
4 | }
5 |
--------------------------------------------------------------------------------
/src/components/navbar/Navbar.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import { Component } from 'vue-property-decorator';
3 | import { Route } from 'vue-router';
4 |
5 | import { ILink } from '@/components/navbar/types.ts';
6 | import { logger } from '@/utils/logger';
7 |
8 | /**
9 | * NavbarComponent
10 | */
11 | @Component({
12 | template: require('./navbar.html'),
13 | watch: {
14 | $route(current: Route, previous: Route): void {
15 | logger.info(`Changed current path to: ${this.$route.path}`);
16 | }
17 | }
18 | })
19 | export class Navbar extends Vue {
20 | public links: ILink[] = [
21 | { name: 'Home', path: '/' },
22 | { name: 'About', path: '/about' },
23 | { name: 'List', path: '/list' }
24 | ];
25 |
26 | public mounted(): void {
27 | this.$nextTick(() => logger.info('Navbar mounted'));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/components/navbar/index.ts:
--------------------------------------------------------------------------------
1 | export * from './Navbar';
2 |
--------------------------------------------------------------------------------
/src/components/navbar/navbar.html:
--------------------------------------------------------------------------------
1 |
2 | Vue-Webpack-TypeScript
3 |
4 |
5 |
6 |
7 | {{link.name}}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/components/navbar/types.ts:
--------------------------------------------------------------------------------
1 | export interface ILink {
2 | name: string;
3 | path: string;
4 | }
5 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vue.js Webpack for TypeScript
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Footer
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Vuetify from 'vuetify';
3 |
4 | import { Navbar } from '@/components/navbar';
5 | import { router } from '@/router';
6 | import { logger } from '@/utils';
7 |
8 | Vue.use(Vuetify);
9 |
10 | // tslint:disable-next-line: no-unused-expression
11 | new Vue({
12 | el: '#app-main',
13 | // https://github.com/vuetifyjs/vuetify/issues/6895#issuecomment-510640903
14 | vuetify: new Vuetify(),
15 | router,
16 | data: { loading: true },
17 | components: {
18 | navbar: Navbar
19 | },
20 | created(): void {
21 | logger.info('Created');
22 | },
23 | mounted(): void {
24 | logger.info('Mounted');
25 | },
26 | methods: {}
27 | });
28 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | // https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills
2 |
3 | // tslint:disable-next-line: no-console
4 | console.log('polyfills');
5 |
--------------------------------------------------------------------------------
/src/router.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import VueRouter from 'vue-router';
3 |
4 | import * as component from '@/components';
5 |
6 | Vue.use(VueRouter);
7 |
8 | export const router: VueRouter = new VueRouter({
9 | routes: [
10 | { path: '/', component: component.Home },
11 | { path: '/about', component: component.About },
12 | { path: '/list', component: component.List }
13 | ]
14 | });
15 |
--------------------------------------------------------------------------------
/src/styles/style.css:
--------------------------------------------------------------------------------
1 | /*#region Vuetify*/
2 | .theme--light .list,
3 | .theme--light .card,
4 | .theme--light .table,
5 | .theme--light .input-group.input-group--solo {
6 | background-color: #FAFAFA;
7 | }
8 | /*#endregion Vuetify*/
9 |
--------------------------------------------------------------------------------
/src/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from './logger';
2 |
--------------------------------------------------------------------------------
/src/utils/logger.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Logs
3 | */
4 | export class Logger {
5 | // tslint:disable:no-console
6 | public info(message: string): void {
7 | console.info(message);
8 | }
9 |
10 | public warn(message: string): void {
11 | console.warn(message);
12 | }
13 |
14 | public error(message: string): void {
15 | console.error(message);
16 | }
17 | // tslint:enable:no-console
18 | }
19 |
20 | export const logger: Logger = new Logger();
21 |
--------------------------------------------------------------------------------
/src/vendor.ts:
--------------------------------------------------------------------------------
1 | // tslint:disable:no-import-side-effect
2 |
3 | import '@mdi/font/css/materialdesignicons.css';
4 | import 'material-design-icons-iconfont/dist/material-design-icons.css';
5 | import 'vuetify/dist/vuetify.min.css';
6 |
7 | import '@/styles/style.css';
8 |
9 | // tslint:enable:no-import-side-effect
10 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "*": ["typings/*"],
6 | "@/*": ["src/*"]
7 | },
8 | "target": "es5",
9 | "outDir": "dist",
10 | "module": "es2015",
11 | "moduleResolution": "node",
12 | "declaration": true,
13 | "strict": true, // noImplicitAny, noImplicitThis, alwaysStrict, strictBindCallApply, strictNullChecks, strictFunctionTypes, strictPropertyInitialization
14 | "noImplicitReturns": true,
15 | "noUnusedLocals": true,
16 | "noFallthroughCasesInSwitch": true,
17 | "removeComments": true,
18 | "sourceMap": true,
19 | "inlineSources": true,
20 | "forceConsistentCasingInFileNames": true,
21 | "experimentalDecorators": true,
22 | "emitDecoratorMetadata": true
23 | },
24 | "include": [
25 | "src/**/*",
26 | "typings/*.d.ts"
27 | ],
28 | "exclude": [
29 | "node_modules"
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint-microsoft-contrib",
3 | "rules": {
4 | "no-parameter-properties": false,
5 | "no-unsafe-any": false,
6 | "no-void-expression": [true, "ignore-arrow-function-shorthand"],
7 |
8 | // import { ... } from '@/...';
9 | "no-implicit-dependencies": [true, ["@"]],
10 | "no-submodule-imports": false,
11 |
12 | // template: require('./template.html')
13 | "no-require-imports": false,
14 |
15 | // watch: $route()
16 | "function-name": false,
17 |
18 | "import-name": false,
19 | "strict-boolean-expressions": false
20 | }
21 | }
22 |
--------------------------------------------------------------------------------