You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote db.ts and inserted it in composables folder.
and, I adjusted the dexie in nuxt3, but i got the error like this.
I imported the module itself. it worked well. I think that composable way is bug or something wrong.
Below is source code of composable way.
Please help me!
Uncaught (in promise) SyntaxError: Identifier 'MySubClassedDexie' has already been declared
db.ts
// db.tsimportDexie,{Table}from"dexie";
export interfaceFriend{id?: number;
name: string;
age: number;}exportclassMySubClassedDexieextendsDexie{// 'friends' is added by dexie when declaring the stores()// We just tell the typing system this is the casefriends!: Table<Friend>;constructor(){super("myDatabase");this.version(1).stores({friends: "++id, name, age",// Primary key and indexed props});}}constdb=newMySubClassedDexie();exportdefaultdb;
App.vue
<template><fieldset><legend>Add new friend</legend><label>
Name:
<inputv-model="friendName"type="text"/></label><br/><label>
Age:
<inputv-model="friendAge"type="number"/></label><br/><button @click="addFriend">Add Friend</button><p>{{ status }}</p></fieldset></template><scriptsetuplang="ts">import{ ref }from"vue";conststatus=ref("");constfriendName=ref("");constfriendAge=ref(20);constaddFriend=async()=>{try{// Add the new friend!constid=awaitdb.friends.add({name: friendName.value,age: friendAge.value,});status.value=`Friend ${friendName.value} successfully added. Got id ${id}`;// Reset form:friendName.value="";friendAge.value=10;}catch(error){status.value=`Failed to add${friendName.value}: ${error}`;}};</script>
The text was updated successfully, but these errors were encountered:
I wrote db.ts and inserted it in composables folder.
and, I adjusted the dexie in nuxt3, but i got the error like this.
I imported the module itself. it worked well. I think that composable way is bug or something wrong.
Below is source code of composable way.
Please help me!
Uncaught (in promise) SyntaxError: Identifier 'MySubClassedDexie' has already been declared
The text was updated successfully, but these errors were encountered: