<template #icon> <DocumentationIcon /> </template> <template #heading>Documentation</template>
时间: 2024-10-15 07:03:43 浏览: 27
这段HTML代码展示了Vue.js中的动态模板插槽(slot)使用示例。`<template>`标签内的`#icon`和`#heading`是模板插槽的标识符(也叫别名)。它们分别对应两个不同的内容区域:
1. `<template #icon>`:这是一个占位符,表示可以在该位置插入自定义的`<DocumentationIcon />`组件。这意味着当你在父组件中引用这个插槽时,可以传递`DocumentationIcon`组件的内容到这里。
2. `<template #heading>`:同样的,这是另一个占位符,用于放置文档标题“Documentation”。在实际使用中,你可能会在这里提供一个文本、H1标签或其他类型的头部信息。
在父组件中,你可以通过`:slot="iconName"` 或者 `v-slot`的方式绑定数据并动态插入到`#icon`插槽,同样地,通过类似的方式传入`heading`的文本。
```html
<!-- 父组件 -->
<ParentComponent :heading="documentTitle" :iconSlot="selectedIcon" />
<!-- 具体使用时 -->
<ParentComponent>
<template slot="icon">
<CustomIcon />
</template>
<template slot-scope="{ iconName }">
<span v-if="iconName === 'doc'" slot="heading">Documentation</span>
</template>
</ParentComponent>
```
阅读全文
相关推荐
添加商品信息,类型为甜品,颜色为粉色,重量为100克。根据上面的要求完善一下以下代码。 芋你啵啵 ¥40.00 <input class="form-control" type="number" value="1"> ¥40.00 Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CXF - Service list</title></head><body>Available SOAP services:
IBgsOutServicedeclarationqureyStatusqureyDecldeclarationBgsoutDocument Endpoint address: http://sz.91etg.com:9310/etgwebservice/iBgsOut
WSDL : {http://impl.service.bgsOut.winlu.com/}BgsOutServiceImplService
Target namespace <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> 图书管理系统 <label>id: </label><input type="text" class="form-control" v-model="id" disabled> <label>name: </label><input type="text" class="form-control" v-model="name" onchange="onchange(id)"> <input type="button" value="添加" class="btn btn-primary" @click. ="add" :disable="isEditable"> id name time {{book.id}} {{book.name}} {{book.time}} 删除 <script src="vue.js"></script> <script> let app = new Vue({ el: '#app', data: { id:0, name:'', books:[ {'id':1,'name':'Vue.js入门','time':new Date()} ], isEditable:true }, mounted(){ this.id=this.books.length+1 console.log(this.id) }, method:{ onchange(){ if (this.name!=''){ this.isEditable=false }else{ this.isEditable=true } }, add(){ this.books.push({'id':this.id,'name':this.name,'time':new Date()}) this.id++ this.name='' }, del(id){ let index=this.books.findIndex((item)=>{ if(item.id==id){ return true } }) this.books.splice(index,1) } } }) </script> </body> </html> 补充代码
Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CXF - Service list</title></head><body>Available SOAP services:
IBgsOutServicedeclarationqureyStatusqureyDecldeclarationBgsoutDocument Endpoint address: http://sz.91etg.com:9310/etgwebservice/iBgsOut
WSDL : {http://impl.service.bgsOut.winlu.com/}BgsOutServiceImplService
Target namespace <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script> </head> <body> 图书管理系统 <label>id: </label><input type="text" class="form-control" v-model="id" disabled> <label>name: </label><input type="text" class="form-control" v-model="name" onchange="onchange(id)"> <input type="button" value="添加" class="btn btn-primary" @click. ="add" :disable="isEditable"> id name time {{book.id}} {{book.name}} {{book.time}} 删除 <script src="vue.js"></script> <script> let app = new Vue({ el: '#app', data: { id:0, name:'', books:[ {'id':1,'name':'Vue.js入门','time':new Date()} ], isEditable:true }, mounted(){ this.id=this.books.length+1 console.log(this.id) }, method:{ onchange(){ if (this.name!=''){ this.isEditable=false }else{ this.isEditable=true } }, add(){ this.books.push({'id':this.id,'name':this.name,'time':new Date()}) this.id++ this.name='' }, del(id){ let index=this.books.findIndex((item)=>{ if(item.id==id){ return true } }) this.books.splice(index,1) } } }) </script> </body> </html> 补充代码
WSDL : {http://impl.service.bgsOut.winlu.com/}BgsOutServiceImplService
Target namespace