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年多没有写博客,感觉很多知识点生疏了,虽然工作上能解决问题,但是当别人问到某个知识点的时候,还是迷迷糊糊的,所以坚持写博客是硬道理的,因为大脑不可能把所有的知识点记住,有可能某一天忘了, ...
随机推荐
- jekyll 将纯文本转化为静态网站和博客 静态网站生成器
jekyll 将纯文本转化为静态网站和博客 静态网站生成器 这个貌似对windows 支持不是很好~ 但是有支持,官方说不建议使用
- sklearn.metrics.roc_curve
官方网址:http://scikit-learn.org/stable/modules/classes.html#module-sklearn.metrics 首先认识单词:metrics: ['mɛ ...
- Linux C动态链接库实现一个插件例子
实现一个简单的计算动态链接库:升级动态链接库后,在不重新编译主程序的情况下,直接生效. lib库: #cat math.c #include <stdio.h> int add(int x ...
- Android 控件布局常用的属性
<!--单个控件经常用到android:id —— 为控件指定相应的IDandroid:text —— 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串a ...
- Java中Arrays作用
Arrays类是提供对数组进行排序.查询和修改等操作方法的工具类.(Arrays:尽可进行数组升序排序) 格式:Arrays.sort(数组名); Package Java; import java. ...
- Linux系统用户、组和权限管理
一.用户与组 1.用户与组的概念 在linux系统中,根据系统管理需要将用户分为三种类型: 1.超级用户:root是linux系统的超级用户,对系统拥有绝对权限.由于root用户权限太大,只有在进行系 ...
- ruby 第五次作业 part 1(分类、排序)
movies_controller.rb class MoviesController < ApplicationController def movie_params params.requi ...
- asp.net:Parser Error & HTTP 错误 500.21 - Internal Server Error
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABEcAAAF8CAIAAACiwUIQAAAgAElEQVR4nO2dyZHzOpZGaVEaADNkBB ...
- python flask获取微信用户信息流程
需要了解的几个url 用户第一次访问时的url,包含以下几个参数 https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID& ...
- jmap Unable to open socket file解决
pid:Unable to open socket file: target process not responding or HotSport VM not loadedThe -F option ...