GVKun编程网logo

Laravel 组件构造函数方法仅适用于本地环境(laravel组件有哪些)

22

这篇文章主要围绕Laravel组件构造函数方法仅适用于本地环境和laravel组件有哪些展开,旨在为您提供一份详细的参考资料。我们将全面介绍Laravel组件构造函数方法仅适用于本地环境的优缺点,解答

这篇文章主要围绕Laravel 组件构造函数方法仅适用于本地环境laravel组件有哪些展开,旨在为您提供一份详细的参考资料。我们将全面介绍Laravel 组件构造函数方法仅适用于本地环境的优缺点,解答laravel组件有哪些的相关问题,同时也会为您带来Android备份管理器仅适用于本地传输、angularjs 2.0:无法通过组件构造函数()注入任何内容、angularjs – Angular 2:将视图/ DOM注入组件构造函数、c# – ELMAH适用于本地机器,但不适用于生产的实用方法。

本文目录一览:

Laravel 组件构造函数方法仅适用于本地环境(laravel组件有哪些)

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备份管理器仅适用于本地传输

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.

解决方法

我有相同的情况 – 当我运行手动备份(通过adb shell命令)工作,但只使用本地传输.对我来说,解决方案是发布Google Play服务,因为我已经测试了数据备份服务而没有发布GP服务.如果您正在使用Proguard,请检查您的proguard配置

angularjs 2.0:无法通过组件构造函数()注入任何内容

angularjs 2.0:无法通过组件构造函数()注入任何内容

我正在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
我看到你的tsconfig.json不正确.
{ 
  "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注入组件构造函数

angularjs – Angular 2:将视图/ DOM注入组件构造函数

我无法弄清楚如何为组件提供对其视图的引用,以便在显示表单时执行诸如关注输入元素之类的操作.我似乎无法将Element或ng.core.ViewRef或ng.core.View注入构造函数.如何访问视图?

在Angular 1中,我会用$link做到这一点.

您正在寻找的可能是ElementRef及其nativeElement字段,但您应该避免以这种方式访问​​DOM.
我认为更好的方法是添加模板变量,例如< input #inp>并使用@ViewChild(‘inp’)输入访问它.在ngAfterViewInit输入中引用输入元素.

另见angular 2 / typescript : get hold of an element in the template

c# – ELMAH适用于本地机器,但不适用于生产

c# – ELMAH适用于本地机器,但不适用于生产

设置简单,我使用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

解决方法

你在生产中运行IIS7吗?在这里阅读我对类似问题的回答 Elmah,convert to .Net4 vs2010,run on server 2008,does not work

关于Laravel 组件构造函数方法仅适用于本地环境laravel组件有哪些的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android备份管理器仅适用于本地传输、angularjs 2.0:无法通过组件构造函数()注入任何内容、angularjs – Angular 2:将视图/ DOM注入组件构造函数、c# – ELMAH适用于本地机器,但不适用于生产等相关知识的信息别忘了在本站进行查找喔。

本文标签: