<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- vue.js -->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<!-- 1.插值 message 来自下面的变量 -->
<h1>{{ message }}</h1>
<h1 style="color: red">点-{{num}}</h1>
</div>
</body>
<script>
// 引入
const { createApp, ref } = Vue
// 创建
createApp({
//setup 标记 Vue3 支持Vue3的语法 直接定义变量、函数都可以
setup() {
const message = ref("Hello vue!")
const num = ref(123)
return {
message,num
}
}
}).mount('#app')
</script>
</html>
vue3 插值表达式
于 2023-10-17 11:21:19 首次发布