component and slot

使用:

1.component panel

<article class="message">
<div class="message-header">
<p>Hello World</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. <strong>Pellentesque risus mi</strong>, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum <a>felis venenatis</a> efficitur. Aenean ac <em>eleifend lacus</em>, in mollis lectus. Donec sodales, arcu et sollicitudin porttitor, tortor urna tempor ligula, id porttitor mi magna a neque. Donec dui urna, vehicula et sem eget, facilisis sodales sem.
</div>
</article>

2.其中header和body需要传入变量

<article class="message">
<div class="message-header">
<p>{{$title}}</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
{{$content}}
</div>
</article>

3.views.components.index 中 需要引用component模版panel

@component('components.panel')
@slot('title')
hello world
@endslot
@slot('content')
have a nice day
@endslot
@endcomponent

4.如果要传入默认content

panel.blade.php修改如下:

 <article class="message">
<div class="message-header">
<p>{{$title}}</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
{{$slot}}
</div>
</article>

index.blade.php修改如下

@component('components.panel')
@slot('title')
hello world
@endslot
have a nice day
@endcomponent //可多来几个: @component('components.panel')
@slot('title')
hello world
@endslot
have a nice day123
@endcomponent

5.还可以这样给默认值:title默认为laravel

panel.blade.php修改如下:

     <article class="message">
<div class="message-header">
<p>{{$title ?? 'laravel'}}</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
{{$slot}}
</div>
</article>
index.blade.php修改如下 @component('components.panel')
have a nice day
@endcomponent

component and slot的更多相关文章

  1. react slot component with args

    react slot component with args how to pass args to react props child component https://codesandbox.i ...

  2. Vue.js-----轻量高效的MVVM框架(十一、使用slot分发内容)

    #单个slot html: <h3>#单个slot</h3> <!-- 定义child01模板 --> <template id="child01& ...

  3. vue插槽slot的理解与使用

    一.个人理解及插槽的使用场景 刚开始看教程我的疑惑是为什么要用插槽,它的使用场景是什么,很多解释都是“父组件向子组件传递dom时会用到插槽”,这并不能很好的解决我的疑惑.既然你用了子组件,你为什么要给 ...

  4. Vue.js——60分钟组件快速入门(下篇)

    概述 上一篇我们重点介绍了组件的创建.注册和使用,熟练这几个步骤将有助于深入组件的开发.另外,在子组件中定义props,可以让父组件的数据传递下来,这就好比子组件告诉父组件:"嘿,老哥,我开 ...

  5. Vue.js学习 Item11 – 组件与组件间的通信

    什么是组件? 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能.在有 ...

  6. Vue.js——60分钟组件快速入门

    一.组件简介 组件系统是Vue.js其中一个重要的概念,它提供了一种抽象,让我们可以使用独立可复用的小组件来构建大型应用,任意类型的应用界面都可以抽象为一个组件树: 那么什么是组件呢?组件可以扩展HT ...

  7. vue源码逐行注释分析+40多m的vue源码程序流程图思维导图 (diff部分待后续更新)

    vue源码业余时间差不多看了一年,以前在网上找帖子,发现很多帖子很零散,都是一部分一部分说,断章的很多,所以自己下定决定一行行看,经过自己坚持与努力,现在基本看完了,差ddf那部分,因为考虑到自己要换 ...

  8. vue.js插槽

    具体讲解的url https://github.com/cunzaizhuyi/vue-slot-demo //例子 用jsfiddle.net去运行就好 <!DOCTYPE html> ...

  9. Vue2 第二天学习

    个人小总结:1年多没有写博客,感觉很多知识点生疏了,虽然工作上能解决问题,但是当别人问到某个知识点的时候,还是迷迷糊糊的,所以坚持写博客是硬道理的,因为大脑不可能把所有的知识点记住,有可能某一天忘了, ...

随机推荐

  1. nginx php 配置模板

    server {     listen 80;     server_name    www.xxx.com;     #access_log     logs/www.xxx.com.access. ...

  2. 中国版 Office 365 (X-Tenant / Tango) 功能验证报告 - 1 简介

    花了点时间做了一次Office 365 X-Tenant的 POC,对过程做了记录和总结,在这里会陆续分享: (一) 简介 这次POC的系统环境是模拟一个公司的生产环境: 1. 公司总部在国外,拥有 ...

  3. swift 待研备份

    https://www.ctolib.com/topics-115290.html 但是还是用到了一个叫做 The Protocol Witness Table (PWT) 的函数表 https:// ...

  4. pavenet资源

    网络结构:http://www.cnblogs.com/fariver/p/7449563.html 源码:https://github.com/sanghoon/pva-faster-rcnn 训练 ...

  5. 单文件组件.vue---父子组件通信

    每一个.vue 文件就是一个 组件,组件和组件相互组合,就成了一个应用,这就涉及到的组件和组件之间的通信,最常用的就是父子之间的通信.在vue 中, 在一个组件中通过 import 引入另一个组件,这 ...

  6. JavaSE-11 接口

    学习要点 接口的定义 接口作为约定 接口作为能力 接口 为什么使用接口 需求描述 要求实现防盗门的功能(防盗门:带锁的门). 需求分析 门有“开”和“关”的功能,锁有“上锁”和“开锁”的功能. 将门和 ...

  7. 在vue中场景,循环行,点击当前行编辑数据

    当前列表 点击编辑,行变为编辑框. <Row style="color:#999;margin-bottom:11px"> <Row style="ma ...

  8. 面向UI编程思想

    UI编程思想: 模块化+组合 模块化是分解: 组合是合成: https://www.cnblogs.com/feng9exe/p/11044134.html

  9. Oracle learning note

    oracle SQL select 'para1' || 'para2' as "para" must "" from table t where c.name ...

  10. 两种js下载文件的方法(转)

    function DownURL(strRemoteURL, strLocalURL){ try{ var xmlHTTP = new ActiveXObject("Microsoft.XM ...