- fix: to export a Component in typescript, you need to create index.ts in each subfolder of the components folder !
This commit is contained in:
3
src/components/categories/SingleCat/SingleCat.scss
Normal file
3
src/components/categories/SingleCat/SingleCat.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.mycard {
|
||||
visibility: hidden;
|
||||
}
|
||||
18
src/components/categories/SingleCat/SingleCat.ts
Normal file
18
src/components/categories/SingleCat/SingleCat.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import Vue from 'vue'
|
||||
import { Component, Prop } from 'vue-property-decorator'
|
||||
|
||||
require('./SingleCat.scss')
|
||||
|
||||
import { ICategory } from '../../../model/index'
|
||||
|
||||
@Component({
|
||||
|
||||
})
|
||||
export default class SingleCat extends Vue {
|
||||
@Prop({required: true}) itemcat: ICategory
|
||||
|
||||
created() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
8
src/components/categories/SingleCat/SingleCat.vue
Normal file
8
src/components/categories/SingleCat/SingleCat.vue
Normal file
@@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div id="appsinglecat">
|
||||
Descr: {{ itemcat.descr_it }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./SingleCat.ts">
|
||||
</script>
|
||||
1
src/components/categories/SingleCat/index.ts
Normal file
1
src/components/categories/SingleCat/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {default as SingleCat} from './SingleCat.vue'
|
||||
@@ -1,10 +1,15 @@
|
||||
import Vue from 'vue'
|
||||
import { Component } from 'vue-property-decorator'
|
||||
|
||||
import { SingleCat } from '@components'
|
||||
import { ICategory } from '@src/model'
|
||||
|
||||
require('./category.scss')
|
||||
|
||||
|
||||
@Component({})
|
||||
@Component({
|
||||
components: { SingleCat }
|
||||
})
|
||||
export default class Category extends Vue {
|
||||
filter: boolean = false
|
||||
category: string = ''
|
||||
@@ -20,21 +25,37 @@ export default class Category extends Vue {
|
||||
this.updatetable()
|
||||
}
|
||||
|
||||
initcat() {
|
||||
|
||||
const objcat: ICategory = {
|
||||
id: 0,
|
||||
descr_it: '',
|
||||
descr_en: '',
|
||||
descr_es: ''
|
||||
}
|
||||
return objcat
|
||||
|
||||
}
|
||||
|
||||
async insertCategory() {
|
||||
|
||||
const objcat = this.initcat()
|
||||
|
||||
let myid = 0
|
||||
const mycat = this.category
|
||||
objcat.descr_it = this.category
|
||||
|
||||
// Add to Indexdb
|
||||
await this.$db.categories.add(
|
||||
{ descr_it: mycat }
|
||||
await this.$db.categories.add(objcat
|
||||
).then(ris => {
|
||||
myid = ris
|
||||
})
|
||||
|
||||
// created_at: new Date(),
|
||||
|
||||
objcat.id = myid
|
||||
|
||||
// Add into the memory
|
||||
this.categories_arr.push({ descr_it: mycat, id: myid })
|
||||
this.categories_arr.push(objcat)
|
||||
|
||||
this.updatetable()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<q-page>
|
||||
<div class="panel">
|
||||
<p class="caption">Category:</p>
|
||||
<p class="caption">Singlecat:</p>
|
||||
|
||||
<q-input v-model="category" inverted float-label="Inserisci la Categoria"
|
||||
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
<ul>
|
||||
Lista:
|
||||
<li v-for="item in categories_arr" :key="item.id"> {{ item.descr_it }} </li>
|
||||
|
||||
<SingleCat :itemcat='mycat' v-for="mycat of categories_arr" :key="mycat.id"/>
|
||||
</ul>
|
||||
</div>
|
||||
</q-page>
|
||||
|
||||
1
src/components/categories/category/index.ts
Normal file
1
src/components/categories/category/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {default as Category} from './category.vue'
|
||||
2
src/components/categories/index.ts
Normal file
2
src/components/categories/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './SingleCat'
|
||||
export * from './category'
|
||||
2
src/components/index.ts
Normal file
2
src/components/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './categories'
|
||||
|
||||
6
src/model/Categories.ts
Normal file
6
src/model/Categories.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface ICategory {
|
||||
id?: number,
|
||||
descr_it?: string
|
||||
descr_en?: string
|
||||
descr_es?: string
|
||||
}
|
||||
@@ -4,3 +4,5 @@ export * from './signin-option'
|
||||
export * from './signup-option'
|
||||
export * from './key-value'
|
||||
export * from './payload'
|
||||
|
||||
export * from './Categories'
|
||||
|
||||
Reference in New Issue
Block a user