Vue3 data() {}, I need to store data that is used through out a component #8573
Unanswered
greenpdx
asked this question in
Help/Questions
Replies: 2 comments
-
I think you should look at how the
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I suggest not mixing both Options API and Setup() for cleaner code. For new app development consider using <script setup> instead. Your code would look like in plain JS:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
IVue2 has data() { return{ wasm: null }} and was accessed by using this.wasm. I am using vite-plugin-rsw to build my rust code for wasm.
I am confused about <script setup lang="ts"> and <script lang="ts"> export default {} for vue3.
I have a simple work demo https://github.com/greenpdx/vuewasm
In App.vue I use <script setup and init() creates a wasm that other calls can use, works
I created components/About.vue for my web-worker using
<script lang=ts> import init, { wgreet, wstartup} from '../../worker/pkg/' export default { async setup() { let wasm = await init() let workr = wstartup() // new Worker in wasm }, methods: { wtry() {// button click wgreet() // wasm web-worker stuff } } because it uses different wasm source. But that wasm is local to the setup function. How do I make it accessible for other functions in the component? Vue2 used data and this.Beta Was this translation helpful? Give feedback.
All reactions