title: 通过 CDN 使用 Vue 组合式 API
date: 2024-01-29 19:35:08
category:
categories:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通过 CDN 使用 Vue 组合式 API</title> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <style> body { font-family: Arial, Helvetica, sans-serif; }
#app { color: #222; padding: 10px; } </style> </head>
<body> <div id="app"> <span>Message:{{ msg}}</span> <button @click="increment">Click Me</button> </div>
<script> const { createApp, ref } = Vue
const msg = ref('Hello Vue!')
function increment() { msg.value = '你好 Vue!' } const app = createApp({ setup() { return { msg, increment }; } }).mount('#app'); </script> </body>
</html>
|
Author:
Shenhuanjie
Permalink:
https://shenhuanjie.github.io/2026/05/09/1a1e59608b78/
License:
Copyright (c) 2024 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?
💬 互动讨论
欢迎留下你的见解、疑问或心得,精选评论有机会获得积分奖励哦!
使用 GitHub 账号登录评论 · 了解 Utterances
发现错误或有建议?提交反馈