学前端的小伙伴们,肯定也会接触vue吧,下面是我给大家分享的一个我自己做的组件,大家可以一起看看,有什么不懂的或者有什么建议,欢迎大家在评论区留言哦
vue组件化、模块化开发
注册一个组件
<!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="./vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<yinput name="姓名" type="text" mywidth="50%" mycolor="red"></yinput>
<yinput name="账号" type="text" mywidth="50%" mycolor="red"></yinput>
<yinput name="密码" type="password" mywidth="50%" mycolor="red"></yinput>
</div>
<script>
Vue.component("yinput",{
props:["name","type","mywidth","mycolor"],
template:"<div><label for ='y'>{{name}}</label><input :type = 'type' id ='y' :style = '{width: mywidth,color: mycolor}'></div>"
})
var vu = new Vue({
el:"#app",
data:{
},
methods:{
}
})
</script>
</body>
</html>