我正在尝试将innovastudios contentbuilder.js(http://innovastudio.com/content-builder.aspx)整合到我现有的laravel 5项目中并面临一些问题。 JS工作正常,但我遗漏了公共文件夹中的一些图片。
我的网站结构是:
edit.blade.php在这里我正在加载contentbuilder.js,特别是一个片段文件(snippet.blde.php)。这包含了我想要拖放的所有元素
snippets.blade.php文件位于:public / backend / contentBuilder / assets /
加载snippets.blade.php的代码是:
jQuery(document).ready(function ($) {
$("#contentarea").contentbuilder({
//snippetFile: 'assets/minimalist-basic/snippets.html',
snippetFile: "{{asset('backend/contentBuilder/assets/simple/snippets.blade.php')}}",
snippetOpen: true,
toolbar: 'left',
iconselect: 'assets/ionicons/selecticon.html'
});
});
在我的snippets.blade.php中,我使用{{asset('')}}引用了所有图片 这是我的snippets.blade.php:
<div data-thumb="{{asset('backend/contentBuilder/assets/simple/thumbnails/theme1_thumb.png')}}">
<div class="container">
<div class="row" style="height: 900px; width: 635px; overflow: hidden; margin: auto;">
<img class="img-noscale" src='{{asset('backend/contentBuilder/assets/simple/images/6.jpg')}}' style="height: 100%; width: 100%; position: relative;" />
</div>
</div>
</div>
我在视图中得到的错误是: “http://localhost:8000/backend/flyers/10/%7B%7Basset('backend / contentBuilder / assets / simple / thumbnails / theme1_thumb.png')%7D%7D 404(未找到)”
看起来{{assets('...')}}没有指向我的公共文件夹! 知道为什么吗?
答案 0 :(得分:3)
我认为问题在于您提供的JS代码段。
而不是使用asset()
助手定义snippetFile,
在file.blade.php
<head>
标记内的<head>
<script> var base_url = "{{asset('/')}}"; </script>
...
... your script file included here
</head>
开头添加此代码段。
所以,你的刀片看起来像这样
jQuery(document).ready(function ($) {
$("#contentarea").contentbuilder({
//snippetFile: 'assets/minimalist-basic/snippets.html',
snippetFile: base_url + "backend/contentBuilder/assets/simple/snippets.blade.php",
snippetOpen: true,
toolbar: 'left',
iconselect: 'assets/ionicons/selecticon.html'
});
});
在你的JS代码中
blade.php
另外,我认为可能还有另一个小问题。
如果view()
未通过控制器通过function returnThumbnail(Request $request) {
return view('snippet');
}
返回,则不会处理snippet.blade.php
。
所以,在你的控制器中添加一个像这样处理刀片的方法
resources/views
确保Route::get('/path/to/snippet', 'YourController@returnThumbnail');
位于jQuery(document).ready(function ($) {
$("#contentarea").contentbuilder(
snippetFile: base_url + "path/to/snippet",
snippetOpen: true,
toolbar: 'left',
iconselect: 'assets/ionicons/selecticon.html'
});
文件夹中。
然后添加这样的路线
Add-Migration MyFirstMigration
并且,在您的Javascript中,
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions'1[Microsoft.EntityFrameworkCore.DbContext]' while attempting to activate 'DAL.DataBaseContext'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet'1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at
Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet'1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet'1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet '1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType, ServiceProvider serviceProvider) at System.Collections.Concurrent.ConcurrentDictionaryExtensions.GetOrAdd[TKey,TValue,TArg](ConcurrentDictionary'2 dictionary, TKey key, Func'3 valueFactory, TArg arg) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.EntityFrameworkCore.Design.DbContextOperations.<>c__DisplayClass13_2.<FindContextTypes>b__6() at Microsoft.EntityFrameworkCore.Design.DbContextOperations.CreateContext(Func'1 factory) at Microsoft.EntityFrameworkCore.Design.DbContextOperations.CreateContext(String contextType) at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.AddMigration(String name, String outputDir, String contextType) at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsAddCommand.Execute(CommonOptions commonOptions, String name, String outputDir, String context, String environment, Action'1 reporter)
at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsAddCommand.<>c__DisplayClass0_0.<Configure>b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions'1[Microsoft.EntityFrameworkCore.DbContext]' while attempting to activate 'DAL.DataBaseContext'.