小编use*_*939的帖子

记忆游戏与角度

我正在重建一个记忆游戏,以熟悉控制器的视图语法.我把问题缩小到了检查功能; 但我可能错了.检查功能将卡作为参数传递但是当我使用console.log(卡)时,卡没有值,当卡应该具有数组平假名或可选字母的值.

   (function() {

// constant variables 
var constants = new (function() {
    var rows = 3;
    var columns = 6;
    var numMatches = (rows * columns) / 2;
    this.getRows = function() { return rows; };
    this.getColumns = function() { return columns; };
    this.getNumMatches = function() { return numMatches; };
})();

// Global Variables
var currentSessionOpen = false;
var previousCard = null;
var numPairs = 0;

// this function creates deck of cards that returns an …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-controlleras

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

在 ReactJS 中包含 SVG 的正确方法是什么?

我只想在我的 reactjs 应用程序中渲染三个 svg 图像。我遇到了数十篇文章和帖子,但想知道在 Reactjs (2019) 中呈现 svg 的最佳/正确方法是什么???

最初我使用“object type="image/svg+xml" data{...} .... 我了解到这不是渲染 svgs 的正确方法。

然后我了解到“xlink:href”=>“xlinkHref in Reactjs”是/是渲染 svgs 的最佳实践,但这在我的 React 应用程序中不起作用。

有人可以告诉我 xlinkHref 是否是在 Reactjs (2019) 中渲染 svgs 的正确方法?如果没有,可以请一些人指出我的方向吗?

编辑:使用解决方案更新。

import React, {Component} from 'react';
import {Link} from 'react-router-dom';
import Icon from './SvgIcons';

class PrimaryFourCol extends Component {
    render() {
        return (
            <div className="full-width-row home-primary-bg">
                <div className="row-container">
                    <h1 className="h1-header text-center lrg-btn-sp">My Skillset</h1>
                    <div className="four-col-primary__container">

                        <div className="four-col-primary__container__item">
                            <Icon name="coffee" className="our-col-primary__container__item__icon" />

                            <h3 className="four-col-primary__container__item__header">
                                Front End Development
                            </h3>
                            <p …
Run Code Online (Sandbox Code Playgroud)

svg reactjs

4
推荐指数
2
解决办法
7070
查看次数

django 2.2.5 url 路径中的 URL 正则表达式

我想在 url 中的单个视图中支持上述视图...在我的搜索中,我遇到了这篇文章,该文章不再受支持,并且我找到的所有教程都已过时,其中演示了如何完成任务Django 1.8.3。

在“products/views.py”中,我创建了产品和详细信息的视图。ProductListView 将显示所有产品,而 ProductDetailView 将显示单个产品详细信息(标题、描述、价格等)。

产品/views.py

class ProductListView(ListView):
    queryset = Product.objects.all()
    template_name = "products/list.html"


class ProductDetailView(DetailView):
    queryset = Product.objects.all()
    template_name = "products/detail.html"
Run Code Online (Sandbox Code Playgroud)

products/urls.py 包含 ProductListView 和 ProductDetailView 视图的路径。ProductListView 似乎是正确的。ProductDetailView 不正确!我收到以下警告:

警告: ?: (2_0.W001) 您的 URL 模式 '^products/(?P\d+)/$' [name='details'] 的路由包含 '(?P<',以 '^' 开头,或以“$”结尾。这可能是迁移到 django.urls.path() 时的疏忽。

ecommerce.py/urls.py 是我包含产品和详细信息网址的地方

电子商务/urls.py:

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

from .views import home, about, contact

urlpatterns = [
    path('admin/', admin.site.urls), …
Run Code Online (Sandbox Code Playgroud)

python django django-urls django-views

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

无法解析符号 useParams

我正在创建一个使用 WebStorm 做出反应的应用程序。我正在尝试使用 react-router-dom useParams。我有 react-router-dom 5.1.2 作为依赖项,但 useParams 在 import 语句中是灰色的。当我将鼠标悬停在 useParams 上时,它会显示“无法解析符号 useParams”。我也在尝试导入 Switch,但我收到了类似的消息“无法解析符号 Switch”。更不寻常的是 Link 是从 react-router-dom 导入的。

在此处输入图片说明 在此处输入图片说明在此处输入图片说明

webstorm reactjs react-router react-router-dom react-hooks

4
推荐指数
2
解决办法
3592
查看次数

将Fancybox插件转换为Angular指令

我正在使用每个按钮中的iframe {{item.details}} ng-repeat网址,这是正常的. HTML:

<a class="various small_button shadow none" fancybox ng-href="{{item.details}}">View Details</a>
Run Code Online (Sandbox Code Playgroud)

问题是创建一个指令,用于fancyboxlightbox iframe单击按钮时创建.我试图通过查看post1post 2以及其他一些帖子来解决这个问题,它们 很有用,但在这种情况下不是解决方案.

Fancybox指令:

app.directive('fancybox', function(){
    return{
        restrict: 'e',

        link: function(scope, element, attrs){

            element.fancybox({  
                type        :'iframe',
                scrolling   : 'no',
                maxWidth    : 800,
                maxHeight   : 400,
                fitToView   : true,
                width       : '70%',
                height      : '70%',
                autoSize    : false,
                closeClick  : true,
                openEffect  : 'none',
                closeEffect : 'none',
                source      :function(current){
                    return $(current.element);

                }
            });
        }
    } …
Run Code Online (Sandbox Code Playgroud)

iframe jquery fancybox angularjs angularjs-directive

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

使用角度缩放大图像以适应屏幕宽度

我想使用 AngularJS 缩放大图像的高度/宽度,使其适合多个设备上的屏幕(响应)。这个网站是我试图完成的一个例子。

angular 是否有一个指令可以处理这个问题,或者我是否需要创建一个指令或工厂来完成这个任务?有没有人尝试过WURFL Image Tailor (WIT)

javascript css image-resizing responsive-design angularjs

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

django.template.exceptions.TemplateDoesNotExist:home.html

django 项目运行良好!主页和其他页面渲染没有问题。我创建产品应用程序/组件页面并意外命名为“模板”模板,因此我将模板重命名为“模板”,当我开始时遇到问题。

我运行终端命令:

  • python 管理.py makemigrations
  • python 管理.py 迁移
  • 蟒蛇收集静态

什么都不起作用!

我收到一条错误消息:

django.template.exceptions.TemplateDoesNotExist:home.html

python django templates

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

函数不返回字符串值

我想从我的消息函数返回m&t的字符串值,以在密码函数中使用以执行while循环,并且一旦错误打印消息反向.我收到的错误消息是"NameError:name'm'未定义",但是在消息中定义了'm',我试图返回以便在密码中使用't'.

def main():
    message()
    cipher(m, t)


def message():
    m = input("Enter your message: ")
    t = ''
    return m, t


def cipher(m, t):
    i = len(m) - 1
    while i >= 0:
        t = t + m[i]
        i -= 1
    print(t)


if __name__ == '__main__': main()
Run Code Online (Sandbox Code Playgroud)

python function return-value

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