小编use*_*334的帖子

Vue js 项目未加载 .env 变量

我正在做一个 Vue JS 项目。我在项目的根目录中创建了一个 .env 文件。我做了3个变量。这是我的 .env 的内容:

API_BASE_URL=http://x.x.x.x:yyyy/myproject
VUE_APP_TITLE=My App
VUE_MY_VAR=My Var
Run Code Online (Sandbox Code Playgroud)

我将日志放在在 beforeMount() 方法中启动时加载的组件中,如下所示:

beforeMount() {
            console.log('base url: ' + process.env.API_BASE_URL);
            console.log('base url: ' + process.env.VUE_APP_TITLE);
            console.log('base url: ' + process.env.VUE_MY_VAR);
        }
Run Code Online (Sandbox Code Playgroud)

当我使用运行开发服务器时,vue-cli-service serve我看到以下控制台输出:

base url: undefined
base url: My App
base url: undefined
Run Code Online (Sandbox Code Playgroud)

我的问题是:为什么 API_BASE_URLVUE_MY_VARundefined的值

npm vue.js

22
推荐指数
1
解决办法
9712
查看次数

Android - 不显示另一个约束布局背景内的约束布局

我正在开展一项Android活动,其中我想要一个标题,以及标题下方的内容.我希望背景图像仅在内容上拉伸,而不是在标题上.

在此输入图像描述

从图片中你可以看到我的图像也在屏幕的徽标部分上拉伸,这是我不想要的.

这是我当前布局的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_11"
    tools:context=".login.LoginActivity"
    >

    <ImageView
        android:id="@+id/logo"
        android:layout_width="381dp"
        android:layout_height="156dp"
        android:src="@drawable/logo"
        tools:ignore="ContentDescription"
        app:layout_constraintTop_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="-480dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:layout_constraintHorizontal_bias="0.47" />

    <ImageView
        android:id="@+id/emptyImage"
        android:layout_width="384dp"
        android:layout_height="445dp"
        android:layout_marginBottom="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="0dp"
        android:background="@color/TICK_BACKGROUND"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo"
        app:layout_constraintVertical_bias="0.0"
        app:srcCompat="@drawable/empty" />

    <EditText
        android:id="@+id/login_usernameTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="80dp"
        android:background="@drawable/rounded_text_edit_shape"
        android:ems="10"
        android:hint="Username"
        android:inputType="textPersonName"
        android:textColor="@color/INPUT_TEXT_COLOR"
        android:textColorHint="@color/iron"
        android:textCursorDrawable="@null"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp" />

    <EditText
        android:id="@+id/login_passwordTextField"
        android:layout_width="291dp"
        android:layout_height="63dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="-38dp"
        android:background="@drawable/rounded_text_edit_shape"
        android:ems="10"
        android:hint="Password"
        android:textCursorDrawable="@null"
        android:inputType="textPassword"
        android:textColor="@color/INPUT_TEXT_COLOR"
        android:textColorHint="@color/iron" …
Run Code Online (Sandbox Code Playgroud)

android android-layout

10
推荐指数
1
解决办法
8456
查看次数

使用自定义 JCE 安全提供程序而不进行签名

我们有自定义的 JCE 安全提供商,它使用我们的智能卡来执行加密操作。

当我们尝试使用某些类(如Cipher、KeyAgreement、KeyGenerator、Mac 或 SecretKeyFactory)时,我们会遇到问题。

Java抛出异常:

Exception in thread "main" java.security.NoSuchProviderException: JCE cannot authenticate the provider Foo
Run Code Online (Sandbox Code Playgroud)

在这里这里读到,如果您尝试使用自定义 JCE 安全提供程序进行加密,则必须对它进行签名。这是因为一些政府中有关密码学的一些法律。

我还阅读了这篇文章: 如何签署自定义 JCE 安全提供程序

看来建议是向 Oracle 邮寄一些有关您公司/产品的信息并发送 csr,以便他们可以颁发可用于代码签名且有效期为 5 年的证书。

我的问题是,有什么办法可以解决这个问题以进行测试吗?例如,通过更改某些策略或对 JAR 进行自签名。我们尝试对 JAR 进行自签名,但没有成功,也许我们做错了什么。

有没有人在没有获得 Oracle 证书的情况下幸运地解决了这个问题?

最后,我们将申请证书,但我读到最多可能需要 10 天才能得到回复,我们需要这个来进行测试。

java security jce jca

5
推荐指数
1
解决办法
1427
查看次数

编译入口点@angular/material/select 失败

当我尝试编译我的 Angular 9 项目时出现错误。

这是我运行 ng serve 时遇到的错误:

ERROR in Failed to compile entry-point @angular/material/select (es2015 as esm2015) due to compilation errors:
node_modules/@angular/material/fesm2015/select.js:2036:26 - error NG1010: Value at position 0 in the NgModule.exports of MatSelectModule is not a reference: [object Object]

2036                 exports: [
                              ~
2037                     CdkScrollableModule,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ... 
2042                     MatCommonModule
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2043                 ],
Run Code Online (Sandbox Code Playgroud)

这是我的 package.json:

{
  "name": "myproject",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e" …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

5
推荐指数
1
解决办法
3431
查看次数

“初始化”:无法从“zallocator&lt;char&gt;”转换为“zallocator&lt;U&gt;”

我试图尝试此页面上给出的 C++ 中的 openssl 示例。该项目示例文件名为 env-encrypt.cxx,可以在该页面上的 tar.gz 内下载。

当我尝试在 Visual Studio 2017 上运行该示例时。我收到以下错误:'Initializing': cannot convert from 'zallocator<char>' to 'zallocator<U>' in file xstring line 1998

这是我得到的输出:

1>------ Build started: Project: ConsoleApplication3, Configuration: Debug Win32 ------
1>ConsoleApplication3.cpp
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xstring(1998): error C2440: 'initializing': cannot convert from 'zallocator<char>' to 'zallocator<U>'
1>        with
1>        [
1>            U=std::_Container_proxy
1>        ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xstring(1998): note: No constructor could take the source type, or constructor overload resolution was ambiguous …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
1054
查看次数

类型“Observable&lt;unknown&gt;”不可分配给类型“Observable&lt;ApiResponse&gt;”

在 Angular 项目中,我在服务中定义了一个函数,该函数应该调用我的 API。

\n

这个函数看起来像这样:

\n
apiCall(type: string, path: string, params: string[], data: any, headers?: HttpHeaders) {\nlet result = new Observable();\nresult = this.http.get(API_URL + '/' + path, {headers});\n\nreturn result.pipe(\n      tap(\n        (response: ApiResponse) => {\n          // console.log(response);\n          return {...response};\n        }),\n      catchError(this.handleError())\n    );\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但是,在最后一行代码中,我收到以下错误:

\n
TS2345: Argument of type 'MonoTypeOperatorFunction<ApiResponse>' is not assignable to parameter of type 'OperatorFunction<unknown, ApiResponse>'. \xc2\xa0\xc2\xa0Types of parameters 'source' and 'source' are incompatible. \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0Type 'Observable<unknown>' is not assignable to type 'Observable<ApiResponse>'. \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0Type 'unknown' is not assignable …
Run Code Online (Sandbox Code Playgroud)

typescript angular

0
推荐指数
1
解决办法
241
查看次数