Closed fengluo2 closed 1 year ago
I need more information
https://github.com/cmp-cc/vue-cookies/blob/master/sample/welcome-v3.html This,He can't work properly
This is a simple example that can be opened directly from the browser without the http server
Is there an error message in f12? You can copy it
oh.This is my problem. I moved the file to another place, causing it to fail to load cookies. js
wait,He still can't seem to work. main.ts
......
const app = createApp(App)
app.use(router)
.use(pinia)
.use(VueCookies)
.use(ElementPlus)
.mount('#app')
......
test.vue
......
<el-button @click="test">test</el-button>
......
<script lang="ts" setup>
const test = () => {
this.$cookies.set("a","b")
}
</script>
......
browser console output error
Uncaught TypeError: Cannot read properties of undefined (reading '$cookies')
at test (test.vue:8:8)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
at emit$1 (runtime-core.esm-bundler.js:718:9)
at runtime-core.esm-bundler.js:7388:53
at handleClick (use-button.ts:46:5)
at createElementBlock.onClick._cache.<computed>._cache.<computed> (button.vue:73:2)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:339:9)
This is not in the lifecycle of Vue. You can study Vue Options API or Composition API,use it.
thank you. I've run it successfully. This gave me a better understanding of vue.
Are you sure to support vue3? The sample example does not work.