标签:虚拟 ini eve border document 很多 ESS 报错 dev
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> <h-title level="1">标题</h-title> <h-title level="2">标题</h-title> <h-title level="3">标题</h-title> </div> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script> Vue.component("h-title",{ /* template渲染 */ // template:` // <div> // <h1 v-if="level==1"><slot></slot></h1> // <h2 v-else-if="level==2"><slot></slot></h2> // <h3 v-else-if="level==3"><slot></slot></h3> // </div> // `, /* render渲染 */ render:function(h){ // createElement(标签名称,属性配置,children) return h("h"+this.level, { attrs:{ "data-id":10 } }, // 相当于<slot></slot>标签接收 this.$slots.default ) }, props:{ level:{ type:String } } }); let vm=new Vue({ el:"#app" }); </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> *{margin: 0;padding: 0;} .btn{ width: 80px; line-height: 40px; text-align: center; color:#fff; border-radius: 5px; background-color: #ccc; } .success{background-color: green;} .error{background-color: red;} .info{background-color: pink;} </style> </head> <body> <div id="app"> <wql-button type="success">成功</wql-button> <wql-button type="info">提示</wql-button> <wql-button type="error">报错</wql-button> <wql-button>默认</wql-button> </div> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> Vue.component("wql-button",{ render:function(h){ return h("div",{ class:{ btn:true, success:this.type=="success", error:this.type=="error", info:this.type=="info" } },this.$slots.default); }, props:{ type:{ type:String } } }); let vm=new Vue({ el:"#app" }); </script> </body> </html>
标签:虚拟 ini eve border document 很多 ESS 报错 dev
原文地址:https://www.cnblogs.com/wuqilang/p/12345512.html