我知道很多人都会问这个问题,但我看了所有答案,但没有任何工作.
我确定问题是我需要创建一个.htaccess文件并将其添加到我的dist中,因为这是ISP控制台指南所说的.
我正在使用Angular cli和build命令:
ng build --aot --prod --base-href ./
Run Code Online (Sandbox Code Playgroud)
我已将此.htaccess文件添加到我的app文件夹 - 与index.html文件相同的文件夹.这是.htaccess代码:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
Run Code Online (Sandbox Code Playgroud)
我在SO上尝试了各种不同答案的各种片段,我尝试了angular.io指南上的片段,我尝试更改base-href.似乎什么都没有用,我甚至无法确定它是否正在构建中正确添加到我的dist中.我能做什么?
我通过 Angular Web 应用程序中的菜单设置了路由。菜单设置了 routerLinks,如下面的主页链接:
<a routerLink="home">
<button md-menu-item>
<md-icon class="material-icons"> home </md-icon>
<span> Home </span>
</button>
</a>
Run Code Online (Sandbox Code Playgroud)
app.router 包含:
export const router: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent },
];
Run Code Online (Sandbox Code Playgroud)
我想在一个组件中有一个按钮,它重定向到一个在普通菜单中不可用的查询表单,但在组件中的按钮上放置链接似乎不起作用。为什么是这样?
对我来说,最理想的做法是在调用路由的组件中的 html 元素中放置一个函数 - 这可能吗?
我正在Pygame上运行这个非常简单的教程:
https://www.youtube.com/watch?v=xh4SV3kF-zk
我无法使游戏窗口识别键盘事件。我已经阅读了许多与此类似的问题,但是答案似乎不适用于Mac。
我正在使用miniconda,可能是我需要退出虚拟环境?我不知道该怎么做。或者,也许我需要将焦点设置到我的窗口上-但我也不知道该怎么做。这一定是很多人在运行El Capitan的Mac上遇到的问题。我的Mac版本太旧,无法正确升级到Sierra。有没有办法让键盘输入起作用?
import pygame
pygame.init()
display_width = 1200
display_height = 800
black = (0, 0, 0)
white = (255, 255, 255)
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('A Bit Racey')
clock = pygame.time.Clock()
speederImg = pygame.image.load('speeder.png')
def speeder(x, y):
gameDisplay.blit(speederImg, (x, y))
x = (display_width * 0.4)
y = (display_height * 0.2)
x_change = 0
crashed = False
while not crashed:
for event in …Run Code Online (Sandbox Code Playgroud) 这个问题就像django 排序,但我无法使任何解决方案起作用。
我有以下模型:
from django.db import models
from django.contrib.auth.models import User
class Product(models.Model):
title = models.CharField(max_length=200)
pub_date = models.DateTimeField()
body = models.TextField()
url = models.TextField()
image = models.ImageField(upload_to='images/')
icon = models.ImageField(upload_to='images/')
votes_total = models.IntegerField(default=1)
hunter = models.ForeignKey(User, on_delete=models.CASCADE)
def summary(self):
return self.body[:50]
def pub_date_pretty(self):
return self.pub_date.strftime('%b %e %Y')
def __str__(self):
return self.title
Run Code Online (Sandbox Code Playgroud)
我想按 votes_total 排序,以便当我遍历数据库时,结果按 votes_total 排序。
{% extends 'base.html' %}
{% block content %}
{% for product in products.all %}
<div class="row pt-3">
<div class="col-2" onclick="window.location='{% url …Run Code Online (Sandbox Code Playgroud) 我正在使用 React Hooks,我想使用 axios hooks 包将图像发送到 Cloudinary。
const [
{ data: putData, loading: putLoading, error: putError },
executePut
] = useAxios(
{
url: 'https://api.myjson.com/bins/820fc',
method: 'PUT'
},
{ manual: true }
)
Run Code Online (Sandbox Code Playgroud)
文档对标题一无所知?
我正在学习关于 Angular4 ngStyle 的教程。
我有以下代码:
应用程序组件.html
<button
[ngStyle]="{
'backgroundColor': canSave ? 'blue': 'gray',
'color': canSave ? 'white': 'black',
'fontWeight': canSave ? 'bold': 'normal'
}"
>
Save
</button>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
canSave = 'false';
}
Run Code Online (Sandbox Code Playgroud)
无论 canSave 是真还是假,我都明白:
控制台看起来像这样:
我不明白为什么这不起作用!三元运算符条件似乎没有任何区别。我的语法错了吗?我直接从教程中复制了它,它似乎在其他情况下也能工作?
我的问题与在角度2中获取mdslider值不同 ? 我需要将滑块的值传递给组件,而不仅仅是使用局部变量。而且还更改了Angular Material,因此滑块现在需要将$ event对象传递给组件函数。
我在Angular 4中有一个Angular Material滑块组件:
的HTML
<mat-slider min="430" max="500" step="10" value="450" (input)="pitch($event)"></mat-slider>
Run Code Online (Sandbox Code Playgroud)
TS
import { Component, OnInit } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { MatSlider } from '@angular/material';
import { AudioContext } from 'angular-audio-context';
@Component({
selector: 'pitch-slider',
templateUrl: './pitch-slider.component.html',
styleUrls: ['./pitch-slider.component.css']
})
export class PitchSliderComponent implements OnInit {
constructor(private _audioContext: AudioContext) { }
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
我对Angular很陌生,在获取滑块的当前值时遇到麻烦。它似乎不适用于$ event对象?
我有一个想要测试的 Django 模型。该模型包括一个“用户”字段。有没有办法创建临时用户以进行测试?
测试.py
from django.test import TestCase
from .models import Task
from django.utils import timezone
from .forms import Taskform
# models test
class TaskTest(TestCase):
def create_task(self, title="Title", description="A description"):
return Task.objects.create(title=title, pub_date=timezone.datetime.now(), completed=False, description=description, user='user')
def test_task_creation(self):
w = self.create_task()
self.assertTrue(isinstance(t, Task))
self.assertEqual(t.__unicode__(), t.title)
Run Code Online (Sandbox Code Playgroud) 我有一个 http onCall 云函数,我想返回一个 signedURL 以允许我将文件上传到云存储桶上一个问题
它一直告诉我权限被拒绝,但我看不出问题出在哪里。函数 GCPSecureURL 设置为 Allow unauthenticated,StorageAdmin 设置为所有用户。
服务帐户还可以访问存储桶上的 StorageAdmin,因为当文件上传到存储桶并触发 pdf 转换服务时,发布/订阅会订阅该事件。
为什么我不能从函数中取回 signedURL?
现在承诺是待定的,然后控制台记录一个 POST 500 错误。该函数的日志显示未处理的错误 { 错误:调用方没有权限” ...
google-cloud-storage google-cloud-platform google-cloud-functions
我有一些时间数据,我需要转换为适当的日期时间
data['dep_time'] = pd.to_datetime(data['dep_time'], format='%H:%M').dt.time
Run Code Online (Sandbox Code Playgroud)
问题出在每个单元格中,我的数字位数不一致
我可能有'1714'或'714'或只是'6'.
我想使用格式将每个str更改为格式00:00,但我必须从str的后面开始并假设如果我只有'6'则表示'00:06'
year month day dep_time dep_delay arr_time arr_delay cancelled \
103992 2014 5 11 1013 -2 1247 -13 0
103993 2014 5 11 1929 -1 2215 -24 0
103994 2014 5 11 1117 5 1355 9 0
103995 2014 5 11 736 -10 924 -18 0
103996 2014 5 11 1340 0 1647 10 0
Run Code Online (Sandbox Code Playgroud) 我有一定数量的产品清单,我需要在Django中对其建模。
每个订单都具有以下属性:
id
email
total_price
line_items
Run Code Online (Sandbox Code Playgroud)
line_items是产品和所需产品实例数的字典。
产品是描述一类产品的单独模型。
我需要在产品和订单之间建立多对多关系,因为每个产品可能是许多订单的一部分,但是每个订单可能有很多产品-如果我的订单中有3个实例,这在我的字段中看起来如何?一个产品,另外2个,等等...?
我需要重新获取 Apollo 查询才能触发 useEffect。我正在实现一个按日期段和文本搜索进行过滤的过滤栏。我的搜索提交按钮触发查询的重新获取,返回的数据是我的 useEffect 的依赖项。返回数据时,如果搜索字段已填充,则应运行过滤器。这在我第一次运行搜索时有效,但是当我使用重置功能重置时,重置被触发,查询在 Chrome 中获得 200 并在 Chrome 开发工具中显示数据,但未触发 useEffect。为什么是这样?
//React
import React, {useState, useContext, useEffect, Fragment } from 'react'
//extra React libraries
//external libraries
import { useQuery, useMutation } from '@apollo/react-hooks'
//components
import AccountsGrid from '../../containers/AccountsGrid/AccountsGrid'
import SpinnerLoader from '../../components/SpinnerLoader/SpinnerLoader'
//styles
import styles from "./accounts.module.scss";
//contexts
import UserContext from '../../containers/contexts/UserContext/UserContext'
import AccountContext from '../../containers/contexts/AccountContext/AccountContext'
//constants
import {
GET_PARENT_ACCOUNT,
SET_ACCOUNTS,
SET_IS_ACTIVE,
SET_ACCOUNTS_LIMIT,
SET_ACCOUNTS_OFFSET,
SET_ACCOUNTS_TOTAL,
SET_ACCOUNTS_START_DATE,
SET_ACCOUNTS_END_DATE,
} from '../../containers/contexts/AccountContext/accountActionTypes'
import {
GET_ACCOUNT_USERS,
GET_ACCOUNTS,
TOTAL_ACCOUNTS,
} from '../../utils/constants/queries/accountQueries' …Run Code Online (Sandbox Code Playgroud) 我在 Google Cloud Run 上有一个非常基本的快速服务,该服务已构建并部署到容器中。它的访问权限设置为允许未经身份验证。
我在前端使用 fetch 和 React 将数据发送到服务器并接收响应。
在服务器上,我似乎无法从我的请求正文中获取数据?无论我对标题等使用什么设置,我都无法从中获取任何数据。
我正在使用 fetch clientside 发送 POST 请求:
const sendData = async() => {
const response = await fetch('https://my-service.run.app', {
method: 'POST',
mode: 'no-cors',
body: { mydata: "some data"},
json: true
});
return response;
}
Run Code Online (Sandbox Code Playgroud)
在服务器上,我的服务超级简单。目前我想要的只是将 json 从客户端发送到云运行服务器,记录它,然后将相同的数据作为响应发送回客户端。但是,控制台日志总是给我一个空对象。
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const {Storage} = require('@google-cloud/storage');
const cors = require('cors');
const corsOptions = {
origin: true,
mode: 'no-cors',
optionsSuccessStatus: 200
};
const port …Run Code Online (Sandbox Code Playgroud) angular ×4
django ×3
python ×2
react-hooks ×2
.htaccess ×1
apache ×1
axios ×1
django-tests ×1
express ×1
foreign-keys ×1
ios ×1
macos ×1
many-to-one ×1
pandas ×1
pygame ×1
react-apollo ×1
reactjs ×1
redirect ×1
routing ×1