简体   繁体   English

在Laravel 5.4包中扩展视图

[英]Extending view in Laravel 5.4 package

I am getting View [layouts.app] not found ErrorException when I extend my app view in another view in a laravel package I am working on. 当我在正在工作的laravel包中的另一个视图中扩展应用程序视图时,得到View [layouts.app] not found ErrorException

This is the directory structure I have for the views: 这是视图的目录结构:

vendor
-Student
--myPackage
---src
----views
-----layouts
------app.blade.phph
-----myView
------viewfile.blade.php

Now If I extend layouts.app like so @extend('layouts.app') in viewfile.blade.php then I get this ErrorException exception. 现在,如果我延长layouts.app像这样@extend('layouts.app')viewfile.blade.php然后我得到这个ErrorException例外。 Although, if I don't extend a layouts.blade view, I can access the view viewfile.blade without any problem. 虽然,如果不扩展layouts.blade视图,则可以viewfile.blade访问layouts.blade视图。

My views are registered like so in the package `ServiceProvider's boot method 我的视图已像在ServiceProvider的启动方法包中那样注册

$this->loadViewsFrom(__DIR__ . '/Views', 'studentViews');

I am using Laravel 5.4 Laravel 5.4 Package Development-Views 我正在使用Laravel 5.4 Laravel 5.4软件包开发视图

You have to add your package name to the view name as stated in the documentation. 您必须按照文档中所述将包名称添加到视图名称。

So you would have to use: 因此,您将必须使用:

@extends('studentViews::layouts.app')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM