fix type errors
diff --git a/components/partials/Navbar.vue b/components/partials/Navbar.vue
index 48e662b..cb988b0 100644
--- a/components/partials/Navbar.vue
+++ b/components/partials/Navbar.vue
@@ -5,8 +5,9 @@
<script lang="ts">
import zhNav from './Navbar/zh';
import enNav from './Navbar/zh';
+import Vue from 'vue';
-export default {
+export default Vue.extend({
components: {
},
@@ -17,6 +18,6 @@
: enNav;
}
}
-};
+});
</script>
diff --git a/components/partials/Sidebar.vue b/components/partials/Sidebar.vue
index 9bd6cc9..5249e33 100644
--- a/components/partials/Sidebar.vue
+++ b/components/partials/Sidebar.vue
@@ -31,10 +31,11 @@
<script lang="ts">
-import SidebarNavItem from './SidebarNavItem';
+import Vue from 'vue';
+import SidebarNavItem from './SidebarNavItem.vue';
import scrollIntoView from 'scroll-into-view';
-export default {
+export default Vue.extend({
components: {
SidebarNavItem
@@ -59,7 +60,7 @@
}
}, 0);
}
-};
+});
</script>
diff --git a/components/partials/SidebarNavItem.vue b/components/partials/SidebarNavItem.vue
index 27fc3fc..a250064 100644
--- a/components/partials/SidebarNavItem.vue
+++ b/components/partials/SidebarNavItem.vue
@@ -27,6 +27,7 @@
:parentPath="path"
:item="child"
:level="level + 1"
+ :key="child.dir"
></SidebarNavItem>
</ul>
</li>
@@ -34,19 +35,36 @@
<script lang="ts">
-export default {
+
+import Vue from 'vue';
+
+interface NavItem {
+ dir: string
+}
+
+export default Vue.extend({
name: 'SidebarNavItem',
- props: ['item', 'parentPath', 'level'],
+ props: {
+ item: {
+ type: Object as () => NavItem
+ },
+ parentPath: {
+ type: String as () => string
+ },
+ level: {
+ type: Number as () => number
+ }
+ },
computed: {
- link() {
+ link(): string {
return this.$store.state.config.rootPath + '/' + this.$store.state.locale
+ '/' + this.path;
},
- isActived() {
+ isActived(): boolean {
return this.$route.params.post === this.path;
}
},
@@ -55,11 +73,11 @@
const path = this.parentPath + '_' + this.item.dir;
const isSelfOrChildActived = this.$route.params.post.startsWith(path);
return {
- get path() {
+ get path(): string {
return path;
},
- collapsed: this.level >= 2 && !isSelfOrChildActived
- }
+ collapsed: (this.level >= 2 && !isSelfOrChildActived) as boolean
+ };
},
methods: {
@@ -67,7 +85,7 @@
this.collapsed = !this.collapsed
}
}
-}
+});
</script>
<style lang="scss">