其他分享
首页 > 其他分享> > VUE框架组件化思维

VUE框架组件化思维

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.5/vue.global.js"></script>

</head>
<body>

<div id="components-demo">
<button-counter></button-counter>
<button-counter></button-counter>
<button-counter></button-counter>
</div>

<script>
// 创建一个Vue 应用
const app = Vue.createApp({})

// 定义一个名为 button-counter 的新全局组件
app.component('button-counter', {
data() {
return {
count: 0
}
},
template: `
<button @click="count++">
You clicked me {{ count }} times.
</button>`,
style:{
color:"red",
}
})
app.mount('#components-demo')
</script>

</body>
</html>

 

标签:count,思维,VUE,app,counter,Vue,组件,button
来源: https://www.cnblogs.com/A121/p/16387170.html