
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="root"></div>
</body>
<script>
const app = Vue.createApp({
// 下面用到变量,这里需要定义
data() {
return {
radioValue: "",
};
},
// 模板
template: `
<h1>{{radioValue}}</h1>
男<input type="radio" v-model="radioValue" id="" value="male"/>
女<input type="radio" v-model="radioValue" id="" value="female"/>
待定<input type="radio" v-model="radioValue" id="" value="unknown"/>
`,
});
const vm = app.mount("#root");
</script>
</html>