Adonis 入门 —— 视图

1、创建视图

adonis make:view Post

2、引用资源

{{ style('css/main') }}
{{ script('js/main') }}

3、方法

3.1 判断

@if(post.title)
   I have a title 
@else
   No, you don't.
@endif

3.2 迭代

@each(entity in entities)
  <small>{{ entity.title }}: {{ entity.content }}</small>
@endeach

4、示例

// 自闭合格式
@!section('content')

// 常规
@section('content')
   <div> default </div>
@endsection

// 引用
@layout('layouts.main')

// 循环
@each(post in posts)
   {{ post }}
@endeach

// 创建slot
@yield($slot.notes)
  <small>Put some notes here.</small>
@endyield

// 使用slot
@slot('notes')
   <small>I'm a slot</small>
@endslot

// 组件
@component('components.list', {
  entities,
  border: true,
  borderColor: '#ddeaf2'
})

// 组件文件 components/list.edge
@each(entity in entities)
  {{ entity.title }}: {{ entity.content }}
@endeach

 

 

说点什么

avatar
  Subscribe  
提醒