Skip to content

localStorage is not defined #151

@zhaoxiuyu

Description

@zhaoxiuyu

I want to use it in HarmonyOS.
I integrate according to the document and then generate the js file.
Integrate and invoke this js in deveco-studio and output the following error message.

ReferenceError: localStorage is not defined
TypeError: Cannot load property of null or undefined

The following are my configuration items:
commonMain.dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kstore)
}
androidMain.dependencies {
implementation(libs.kstore.file)
}
iosMain.dependencies {
implementation(libs.kstore.file)
}
val jsCommonMain by getting {
dependsOn(commonMain.get())
}
jsCommonMain.dependencies {
implementation(libs.kstore.storage)
implementation(libs.kotlinx.coroutines.core.js)
}

commonMain:
expect val storeVehicles: KStore
jsMain:
actual val storeVehicles: KStore by lazy {
storeOf(key = "storeCurrentVehicle")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions