component and slot
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的更多相关文章
- react slot component with args
react slot component with args how to pass args to react props child component https://codesandbox.i ...
- Vue.js-----轻量高效的MVVM框架(十一、使用slot分发内容)
#单个slot html: <h3>#单个slot</h3> <!-- 定义child01模板 --> <template id="child01& ...
- vue插槽slot的理解与使用
一.个人理解及插槽的使用场景 刚开始看教程我的疑惑是为什么要用插槽,它的使用场景是什么,很多解释都是“父组件向子组件传递dom时会用到插槽”,这并不能很好的解决我的疑惑.既然你用了子组件,你为什么要给 ...
- Vue.js——60分钟组件快速入门(下篇)
概述 上一篇我们重点介绍了组件的创建.注册和使用,熟练这几个步骤将有助于深入组件的开发.另外,在子组件中定义props,可以让父组件的数据传递下来,这就好比子组件告诉父组件:"嘿,老哥,我开 ...
- Vue.js学习 Item11 – 组件与组件间的通信
什么是组件? 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能.在有 ...
- Vue.js——60分钟组件快速入门
一.组件简介 组件系统是Vue.js其中一个重要的概念,它提供了一种抽象,让我们可以使用独立可复用的小组件来构建大型应用,任意类型的应用界面都可以抽象为一个组件树: 那么什么是组件呢?组件可以扩展HT ...
- vue源码逐行注释分析+40多m的vue源码程序流程图思维导图 (diff部分待后续更新)
vue源码业余时间差不多看了一年,以前在网上找帖子,发现很多帖子很零散,都是一部分一部分说,断章的很多,所以自己下定决定一行行看,经过自己坚持与努力,现在基本看完了,差ddf那部分,因为考虑到自己要换 ...
- vue.js插槽
具体讲解的url https://github.com/cunzaizhuyi/vue-slot-demo //例子 用jsfiddle.net去运行就好 <!DOCTYPE html> ...
- Vue2 第二天学习
个人小总结:1年多没有写博客,感觉很多知识点生疏了,虽然工作上能解决问题,但是当别人问到某个知识点的时候,还是迷迷糊糊的,所以坚持写博客是硬道理的,因为大脑不可能把所有的知识点记住,有可能某一天忘了, ...
随机推荐
- JavaScript——max-age
https://zhidao.baidu.com/question/391047416053664205.html 页面优化方式之一,延长过期时间.默认max-age=0
- CentOS 6.4 php-fpm 添加service 添加平滑启动/重启
nginx通过FastCGI运行PHP比Apache包含PHP环境有明显的优势,最近有消息称,PHP5.4将很有可能把PHP-FPM补丁包含在内核里,nginx服务器平台上运行PHP将更加轻松,下面我 ...
- 【C++】朝花夕拾——表达式树
表达式树: 叶子是操作数,其余结点为操作符,是二叉树的其中一种应用 ====================我是分割线====================== 一棵表达式树如下图: 若是对它做中序 ...
- 测试ip是否可以ping通
7.写一个脚本hostping.sh,接受一个主机的IPv4地址做为参数,测试是否可连通.如果能ping通,则提示用户“该IP地址可访问”:如果不可ping通,则提示用户“该IP地址不可访问 参考脚本 ...
- JS中二进制与十进制的相互转换
今天在做题目的时候遇到了需要十进制转换为二进制,这个我知道用toString可以,但是二进制转换为十进制我一下子就想不起来,网上搜了下,才知道是parseInt可以实现,特此记录下. 十进制转换为二进 ...
- VC++线程函数内怎么调用外部函数
VC++线程函数内怎么调用外部函数 1.把外部函数做成静态函数,就可以直接调用了.2.把外部函数所在的对象通过线程函数参数传到线程里面来,这样线程里可以使用此对象及其函数了.
- Ubuntu16.04 python3.4.3升级到python3.7.1
python有两个版本,一个2版本,使用的是python:另一个是3版本,使用的是python3. 简易安装python后得到的3版本的版本号是python3.4.3. 可以使用下面的命令查看py版本 ...
- Linux下MySQL 5.7的初始化
要用管理员账号运行. systemctl start mysql#启动MySQL服务 mysqld_safe --user=mysql &#启动MySQL服务(安全方式) mysql -u r ...
- iphone X 的适配
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- PC端样式重置
html{font-family:"Microsoft YaHei UI","Microsoft YaHei",sans-serif;-ms-text-size ...