40 lines
1.1 KiB
HTML
40 lines
1.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>Document</title>
|
||
|
<!-- 1. 导入vue.js的脚本文件 -->
|
||
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<div id="app">
|
||
|
<!-- {{}} 文本插值 -->
|
||
|
<p>{{username}}</p>
|
||
|
<p>{{age}}</p>
|
||
|
<p>{{desc}}</p>
|
||
|
<!-- v-html指令: 显示HTML内容 -->
|
||
|
<p v-html="desc"></p>
|
||
|
</div>
|
||
|
</body>
|
||
|
<script>
|
||
|
// 将 Vue 对象中的createApp reactive 属性赋值给createApp reactive
|
||
|
const { createApp, reactive } = Vue; // 解构赋值语法
|
||
|
// 创建一个 Vue 的应用程序
|
||
|
createApp({
|
||
|
// 组合式API 的 setup 用于设置响应式数据和方法
|
||
|
setup() {
|
||
|
const username = 'Maxxie';
|
||
|
const age = 30;
|
||
|
const desc = '<a href="www.baidu.com">百度</a>'
|
||
|
// 返回数据
|
||
|
return {
|
||
|
username, age, desc
|
||
|
}
|
||
|
}
|
||
|
}).mount('#app') // 将 Vue 应用程序挂载到app元素上
|
||
|
</script>
|
||
|
|
||
|
</html>
|