xxxxxxxxxx
<html>
<head>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<h3>Vue check if checkbox is checked</h3>
<input type="checkbox" id="myCheckbox" v-model="isChecked">
<label for="myCheckbox">Check me</label>
<p>{{ isChecked ? 'Checked' : 'Not checked' }}</p>
</div>
<script type="module">
const app = Vue.createApp({
data() {
return {
isChecked: false
};
}
});
app.mount('#app');
</script>
<style scoped>
/* style for the container */
#app {
margin: 0 auto;
padding: 20px;
width: 400px;
text-align: center;
}
/* style for the heading */
h3 {
font-size: 24px;
margin-bottom: 20px;
}
/* style for the checkbox */
input[type="checkbox"] {
margin-right: 10px;
}
/* style for the label */
label {
font-size: 18px;
}
/* style for the paragraph */
p {
font-size: 18px;
margin-top: 20px;
}
</style>
</body>
</html>