这篇文章主要围绕Laravel组件构造函数方法仅适用于本地环境和laravel组件有哪些展开,旨在为您提供一份详细的参考资料。我们将全面介绍Laravel组件构造函数方法仅适用于本地环境的优缺点,解答
这篇文章主要围绕Laravel 组件构造函数方法仅适用于本地环境和laravel组件有哪些展开,旨在为您提供一份详细的参考资料。我们将全面介绍Laravel 组件构造函数方法仅适用于本地环境的优缺点,解答laravel组件有哪些的相关问题,同时也会为您带来Android备份管理器仅适用于本地传输、angularjs 2.0:无法通过组件构造函数()注入任何内容、angularjs – Angular 2:将视图/ DOM注入组件构造函数、c# – ELMAH适用于本地机器,但不适用于生产的实用方法。
本文目录一览:- Laravel 组件构造函数方法仅适用于本地环境(laravel组件有哪些)
- Android备份管理器仅适用于本地传输
- angularjs 2.0:无法通过组件构造函数()注入任何内容
- angularjs – Angular 2:将视图/ DOM注入组件构造函数
- c# – ELMAH适用于本地机器,但不适用于生产
Laravel 组件构造函数方法仅适用于本地环境(laravel组件有哪些)
如何解决Laravel 组件构造函数方法仅适用于本地环境?
我的组件如下所示:
namespace App\View\Components;
use Illuminate\View\Component;
use App\Http\Controllers;
use Illuminate\Http\Request;
class shopImageContainer extends Component
{
public $image;
public $ph;
public $va;
public $config;
/**
* Create a new component instance.
*@param string $ph
*@param string $va
* @return void
*/
public function __construct($ph,$va,$image)
{
$this->image = $image;
$this->va = $va;
$this->ph = $ph;
$this->config = Controllers\GlobalFunctions::getConfig($ph,$va);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view(''components.shop-image-container'');
}
}
在我的 component.blade 中,我有这一行/块会引发错误“未定义变量:配置”:
@if($config->dd)
<div>
<ahref="/download/{{ basename($image) }}" role="button">Download in {{ $config->ddLongEdge }}px</a>
</div>
@endif
似乎没有调用构造函数方法(我在方法中尝试了 dd("test) 并且没有输出) 有趣的是,它在我的本地环境中工作,但不在服务器上(apache2) 我在某处读到过组件可能存在错误并且服务器的配置可能有问题,在这两种情况下都没有关于解决问题的更多细节。 感谢您的帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
Android备份管理器仅适用于本地传输
我完成了Google文档通知的每个步骤:
在Google服务上注册
Manifest上的更改(allowBackup,backupAgent和backup.api_key(google服务注册)等等…
清单部分:
<application android:allowBackup="true" android:backupAgent="my.package.MybackupmanagerClass"> <Meta-data android:name="com.google.android.backup.api_key" android:value="my-generated-key-by-google-service" />
事实上,备份正在运行,但只使用本地传输,我已经使用bmgr备份/运行/恢复进行了测试:
bmgr list transports * android/com.android.internal.backup.LocalTransport com.google.android.gms/.backup.BackupTransportService
但是当尝试使用Google传输(云:com.google.android.gms / .backup.BackupTransportService)时,它无效,甚至无法从MyBackupAgentHelper调用我的onCreate().
我要提到的一点是,当我跑:
bmgr备份
bmgr跑
在运行命令之后,在logcat上显示了很多“现在暂存备份”(也显示我的应用程序包在此列表中)但它发生得非常快并且看起来事实上并没有完成备份,毕竟,甚至我的MyBackupHelper.onCreate()未被调用:
02-12 21:13:28.889: D/backupmanagerService(547): Now staging backup of com.google.android.talk 02-12 21:13:28.904: D/backupmanagerService(547): Now staging backup of com.google.android.dialer 02-12 21:13:28.907: D/backupmanagerService(547): Now staging backup of com.android.providers.settings 02-12 21:13:28.910: D/backupmanagerService(547): Now staging backup of com.sirma.mobile.bible.android 02-12 21:13:28.914: D/backupmanagerService(547): Now staging backup of com.android.sharedstoragebackup 02-12 21:13:28.919: D/backupmanagerService(547): Now staging backup of com.google.android.gm 02-12 21:13:28.922: D/backupmanagerService(547): Now staging backup of com.android.providers.userdictionary 02-12 21:13:28.926: D/backupmanagerService(547): Now staging backup of com.google.android.apps.genie.geniewidget 02-12 21:13:28.963: I/GmsBackupTransport(1409): Next backup will happen in 86399923 millis. 02-12 21:13:28.967: I/backupmanagerService(547): Backup pass finished.
解决方法
angularjs 2.0:无法通过组件构造函数()注入任何内容
这是plnkr url:https://plnkr.co/edit/g1UcGmYPLtY8GiXuNHzK?p=preview
我使用以下代码从app.item.service.ts导入ItemService
import { ItemService } from './app.item.service';
然后我指定提供者为
@Component({ selector: 'list-todo',template: ` <ul> <li *ngFor="let item of items">{{item.text}}</li> </ul> `,providers : [ItemService] })
之后,给TodoComponent的代码为
export class TodoComponent implements OnInit { items:Array<Object> = []; constructor(private itemService: ItemService){ //here is the problem } ngOnInit(){ this.getItems(); } getItems(){ this.items = this.itemService.getItems(); } }
当我尝试通过构造函数注入ItemService时,我收到一个错误:“错误:无法解析TodoComponent的所有参数:(?).”
我甚至无法注入像Injector这样的angularjs提供者.
但是,这种方法适合我:
const injector = ReflectiveInjector.resolveAndCreate([ItemService]); this.itemService = injector.get(ItemService);
我正在使用我的package.json中提到的以下版本的库进行开发
"dependencies": { "@angular/common": "2.0.0","@angular/compiler": "2.0.0","@angular/core": "2.0.0","@angular/forms": "2.0.0","@angular/http": "2.0.0","@angular/platform-browser": "2.0.0","@angular/platform-browser-dynamic": "2.0.0","@angular/router": "3.0.0","@angular/upgrade": "2.0.0","core-js": "^2.4.1","reflect-Metadata": "^0.1.3","rxjs": "5.0.0-beta.12","systemjs": "0.19.27","zone.js": "^0.6.23","angular2-in-memory-web-api": "0.0.20","bootstrap": "^3.3.6" },"devDependencies": { "concurrently": "^2.2.0","lite-server": "^2.2.2","typescript": "^2.0.2","typings":"^1.3.2" }
> Angular版本:最终2.0.0
>浏览器:全部
附上我从控制台得到的错误日志:
(index):16 Error: Error: Can't resolve all parameters for TodoComponent: (?). at CompileMetadataResolver.getDependenciesMetadata (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14404:21) at CompileMetadataResolver.getTypeMetadata (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14301:28) at CompileMetadataResolver.getDirectiveMetadata (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14074:30) at eval (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14167:51) at Array.forEach (native) at CompileMetadataResolver.getNgModuleMetadata (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14161:51) at RuntimeCompiler._compileComponents (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16803:49) at RuntimeCompiler._compileModuleAndComponents (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16741:39) at RuntimeCompiler.compileModuleAsync (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16732:23) at PlatformRef_._bootstrapModuleWithZone (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:6954:29) Evaluating http://localhost:3000/dist/main.js Error loading http://localhost:3000/dist/main.js(anonymous function) @ (index):16ZoneDelegate.invoke @ zone.js:203Zone.run @ zone.js:96(anonymous function) @ zone.js:462ZoneDelegate.invokeTask @ zone.js:236Zone.runTask @ zone.js:136drainMicroTaskQueue @ zone.js:368ZoneTask.invoke @ zone.js:308
{ "compilerOptions": { "target": "es5","module": "commonjs","moduleResolution": "node","sourceMap": false,"emitDecoratorMetadata": true,<== it should be true "experimentalDecorators": true,"removeComments": false,"noImplicitAny": false,"outDir": "dist" } }
这是DI的神奇酱油. emitDecoratorMetadata:true.此选项将保留对象元数据中的类型信息.
也可以看看
> How does the TypeScript Angular DI magic work?
> Injecting services in services in Angular 2
angularjs – Angular 2:将视图/ DOM注入组件构造函数
在Angular 1中,我会用$link做到这一点.
我认为更好的方法是添加模板变量,例如< input #inp>并使用@ViewChild(‘inp’)输入访问它.在ngAfterViewInit输入中引用输入元素.
另见angular 2 / typescript : get hold of an element in the template
c# – ELMAH适用于本地机器,但不适用于生产
这是我本地机器上的web.config:
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="elmah"> <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler,Elmah" /> <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler,Elmah" /> <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler,Elmah" /> <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler,Elmah" /> </sectionGroup> </configSections> <elmah> <security allowRemoteAccess="0" /> <errorLog type="Elmah.sqlErrorLog,Elmah" connectionStringName="MyDB" /> <errorMail from="errors@mysite.com" to="myemail@mysite.com" subject="Error" smtpServer="localhost" smtpPort="25" userName="user@mysite.com" password="mypassword" /> </elmah> <connectionStrings> <add name="MyDB" connectionString="Data Source=.\sqlEXPRESS AttachDbFilename=|DataDirectory|\MyDB.mdf; Integrated Security=True;User Instance=True; MultipleActiveResultSets=True" providerName="System.Data.sqlClient" /> <!--<add name="MyDB" connectionString="Server=mysite.com; Database=MyDB;User ID=user;Password=mypassword; Trusted_Connection=True;Integrated Security=False; MultipleActiveResultSets=True" providerName="System.Data.sqlClient" />--> </connectionStrings> <system.web> <!--<httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory,Elmah" /> </httpHandlers>--> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule,Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule,Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule,Elmah" /> </httpModules> </system.web> <location path="Admin/Errors"> <system.web> <httpHandlers> <add verb="POST,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory,Elmah" /> </httpHandlers> </system.web> </location> </configuration>
我机器上的web.config与生产之间的唯一区别是正在使用的连接字符串.在我的机器上,我正在连接到.mdf文件.在生产时,我正在连接到外部数据库.
谁能看到我在这里做错了什么?
我正在使用C#和ASP.NET MVC 3
解决方法
关于Laravel 组件构造函数方法仅适用于本地环境和laravel组件有哪些的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android备份管理器仅适用于本地传输、angularjs 2.0:无法通过组件构造函数()注入任何内容、angularjs – Angular 2:将视图/ DOM注入组件构造函数、c# – ELMAH适用于本地机器,但不适用于生产等相关知识的信息别忘了在本站进行查找喔。
本文标签: