我有一个反应式表单,并根据fooRequired我想要将字段设置为必填或非必填的属性。
我无法更改它,因为它是初始设置的。那我能做什么呢?
fooRequired = false;
form = new FormGroup({
foo: new FormControl(null, [Validators.required])
});
toggle() { this.fooRequired = !this.fooRequired; }
Run Code Online (Sandbox Code Playgroud) 每次我想使用 vscode git throw 错误消息从我的 GitHub 存储库执行拉取或推送时,我都会遇到问题:
Error: ENOENT: no such file or directory, watch 'c:\repos\app-repo\.git\refs\remotes\origin\master'
Run Code Online (Sandbox Code Playgroud)
该存储库在 GitHub 中是私有的。在c:\repos\app-repo\.git\refs\remotes\origin我有一个名为 HEAD 的文件。
我该做什么?为什么会发生这个错误?
这是来自 vscode-git-output-control 的完整错误:
git pull --tags origin master
> git show :package.json
From https://github.com/user/app-repo
* branch master -> FETCH_HEAD
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
Failed …Run Code Online (Sandbox Code Playgroud) 我尝试使用crypto-js以下方法加密和解密此字符串:
const str = `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1ZDg5MjMxMjc5OTkxYjJhNGMwMjdjMGIiLCJoc2giOiIkMmEkMTMkWk53Y0cubjdRZFIybDA3S1RHd2RoLlN0QksudW5GSFVGLkZnZ0tQTGlUV2pOVEFqVy9SMm0iLCJncmFudCI6ImFjY2VzcyIsImlhdCI6MTU2OTI2ODUwMiwiZXhwIjoxNjAwODI2MTAyfQ.PQcCoF9d25bBqr1U4IhJbylpnKTYiad3NjCh_LvMfLE~3~null~undefined~434ce0149ce42606d8746bd9`;
Run Code Online (Sandbox Code Playgroud)
但我得到了一个错误:
Error: Malformed UTF-8 data
Run Code Online (Sandbox Code Playgroud)
我做错了什么?我该如何解决?
完整代码也在 stackbliz 上:
import crypto from 'crypto-js';
const str = `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1ZDg5MjMxMjc5OTkxYjJhNGMwMjdjMGIiLCJoc2giOiIkMmEkMTMkWk53Y0cubjdRZFIybDA3S1RHd2RoLlN0QksudW5GSFVGLkZnZ0tQTGlUV2pOVEFqVy9SMm0iLCJncmFudCI6ImFjY2VzcyIsImlhdCI6MTU2OTI2ODUwMiwiZXhwIjoxNjAwODI2MTAyfQ.PQcCoF9d25bBqr1U4IhJbylpnKTYiad3NjCh_LvMfLE~9~null~undefined~434ce0149ce42606d8746bd9`;
const cryptoInfo = crypto.AES.encrypt(str, 'secret').toString();
console.log({ cryptoInfo });
const info2 = crypto.AES.decrypt(str, 'secret').toString(crypto.enc.Utf8);
console.log({ info2 });
Run Code Online (Sandbox Code Playgroud) 我使用 cli v4.4.1 安装 vue。
之后,我运行此命令以更新到 Vue3: vue add vue-next。
当我打开时,main.ts我收到打字稿错误:
Argument of type 'typeof import("c:/../vue-app/node_modules/vue/dist/vue")' is not assignable to parameter of type 'PublicAPIComponent'.
Run Code Online (Sandbox Code Playgroud)
我需要做什么来解决这个错误?
我开始使用ngrx let来使用普通对象。
问题是,当我在组件中使用大量可观察量时,我最终得到的代码似乎很糟糕(ng-container inside ng-container inside ng-container inside ng-container ...):
<ng-container *ngrxLet="obs1$ as obs1">
<ng-container *ngrxLet="obs2$ as obs2">
<ng-container *ngrxLet="obs3$ as obs3">
<ng-container *ngrxLet="obs4$ as obs4">
<app-comp [data]="obs1" ..>..</app-comp>
<app-comp2 [data]="obs1" [data2]="obs3"..>..</app-comp2>
<app-comp3 [data]="obs1" ..>..</app-comp3>
<app-comp4 [data]="obs1" ..>..</app-comp4>
<app-comp5 [data]="obs4" [data11]="obs1" ..>..</app-comp5>
<app-comp6 [data]="obs2" ..>..</app-comp6>
<app-comp7 [data]="obs3" ..>..</app-comp7>
</app-number>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来处理这种语法?
我只想在 cdn.mydomain.com 上提供我的 s3 文件
所以我创建了在https://dxxxxxxxx.cloudfront.net/test.jpg上运行良好的 cloudfront 发行版- 我得到了图像。
现在我想将我的域 atcdn.domain.com与 route53 中的 cloudfront相关联。
所以我创建了 A 记录类型 A-IPv4 地址。与名称cdn.domain.com别名目标我手动放置dxxxxxxxx.cloudfront.net。
但是当我打开网址时:
http://cdn.mydomain.com/test.jpg
我收到错误:
403 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers …Run Code Online (Sandbox Code Playgroud) 我的文件中有nx项目中有带有导入声明的文件,但没有任何用途,我想删除它们。
在 stackoverflow 中搜索后,我找到了在 vscode 中打开文件的答案,然后按alt+shift+o,当未使用声明时,它会删除导入并对导入进行排序。
但我有 10,000 个文件。那么在所有这些文件中是否有一个命令可以执行此操作?我查了一下eslint,但没有规定。
我想在应用程序中强制开发人员使用,[]而不是{{}}在元素属性中使用。
例如,此代码应导致错误(在build / serve / lint时间内):
<mycomponent id="{{i}}">
Run Code Online (Sandbox Code Playgroud)
当前代码是
<mycomponent [id]="i">
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我在 vue 中定义了一个路由:
/users/:userId
Run Code Online (Sandbox Code Playgroud)
哪个指向 UserComponent:
<template>
<div>{{username}}</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我使用computedfrom@vue/composition-api来获取数据。
问题是当路由更改为另一个时userId,通过导航到另一个用户,html 模板中的用户没有像我预期的那样更改。当用户不在列表中时,它也不会重定向。
那么我能做些什么来解决这个问题?
这是我的代码:
<template>
<div>{{username}}</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref, getCurrentInstance } from '@vue/composition-api';
export const useUsername = ({ user }) => {
return { username: user.name };
};
export default defineComponent({
setup(props, { root }) {
const vm = getCurrentInstance();
const userToLoad = computed(() => root.$route.params.userId);
const listOfUsers = [
{ userId: 1, name: 'user1' },
{ userId: 2, …Run Code Online (Sandbox Code Playgroud)