示例
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue Basics</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js" defer></script>
<script src="app.js" defer></script>
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<header>
<h1>Vue Course Goals</h1>
</header>
<section id="user-goal">
<h2>My Course Goal</h2>
<p>{{courseGoal}}</p>
</section>
</body>
</html>
app.js
const app = Vue.createApp({
data() {
return {
courseGoal:'Finish the course and learn Vue!'
}
}
});
app.mount('#user-goal');