2

do we have a way to write compostion api script setup with cdn like this?

<template>
{{message}}
</template>

<script setup>

 message:"welcome"; 



</script>

I searched for it but found no solutions I used it in vue 2 and it is available in vue 3 options api but is there anyway to do the same in script setup? Thanks

1
  • How exactly do you use it with CDN? Vue SFC and script setup in particular should be compiled. It's not valid JS otherwise Commented Sep 8, 2022 at 16:45

1 Answer 1

0

I'm not sure what you want to do, but this will work (playground):

<template>
  {{ message }}
</template>

<script setup>
  const message = "welcome"
</script>

I recommend you to read the Vue Composition API faq.

Sign up to request clarification or add additional context in comments.

1 Comment

have you tried it using the vue cdn link? using the cdn link it don't work like this. but if you use the vue installation then it works. <script src="unpkg.com/vue@next"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.