问题列表 - 第279878页

如何使用'--fix'通过Vue-cli进行修改

我通过vue-cli 3进行了一些项目。
因此Package.json脚本中有一个皮棉,
并且eslint产生了很多错误。
我想使用'--fix'自动解决此问题。
但是我应该在哪里以及在commnad中使用“ --fix”?

eslint vue.js

7
推荐指数
3
解决办法
4919
查看次数

在条件语句中使用 null 条件运算符时,如何处理 null 情况?

假设我这里有以下代码:

static void Main(string[] args)
{
   StringBuilder[] s = new StringBuilder[3];
   if (s[0]?.Length > 0)
   {
       Console.WriteLine("hi");
   }
}
Run Code Online (Sandbox Code Playgroud)

我的理解是 if 语句中的表达式必须是布尔表达式。布尔表达式(我的理解可能是错的)是计算结果为 true 或 false 的表达式。

在这种情况下,null 条件运算符将返回 null,因为引用类型变量数组中元素的默认值为 null。因此,这个 if 语句等价于

bool? x = null;
if (x)
{ 
   // do cool things here */ 
}
Run Code Online (Sandbox Code Playgroud)

但这给了我一个语法错误:无法将 null 转换为 bool。

那么,上面的 StringBuilder 示例是如何工作的呢?我的理解是,上述代码的更好方法应该是将其与空合并运算符结合起来,如下所示:

if (s[0]?.Length > 0 ?? false) {}
Run Code Online (Sandbox Code Playgroud)

谢谢大家:)

.net c#

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

Spring Boot 安全性 - Postman 提供 401 Unauthorized

我正在 Spring Boot 中开发 rest API。我能够进行 CRUD 操作并且邮递员给出正确的响应,但是当我添加 Spring Security 用户名和密码时,邮递员给出 401 Unauthorized。

我提供了一个 spring boot 安全用户名和密码,如下所示。

application.proptries

spring.jpa.hibernate.ddl-auto=update
spring.datasource.platform=mysql
spring.datasource.url=jdbc:mysql://localhost:3306/pal?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.security.user.name=root
spring.security.user.password=root
Run Code Online (Sandbox Code Playgroud)

我已经使用用户名作为 root 和密码作为 root 完成了基本身份验证。预览请求提供标题更新成功消息:

在此处输入图片说明

编辑 我已经删除了邮递员中的 cookie 但仍然面临同样的问题

SecurityConfing.java
My Security Configuration are as below. 
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
@Order(1000)
public class SecurityConfig extends WebSecurityConfigurerAdapter{


    public void configureGlobal(AuthenticationManagerBuilder authenticationMgr) throws Exception { …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot postman

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

如何在matplotlib中检查ax是否是极坐标投影?

是否有一个属性fig可以ax指示轴的投影是否是极坐标?

我正在尝试在一个更复杂的函数中创建一个基本的嵌套函数,该函数本质上具有以下功能:

is_polar(ax):
    return ax.some_attribute
Run Code Online (Sandbox Code Playgroud)

不过,我不确定这是否可能,因为我已经查看了其明显的属性。我想在进行详尽的手动搜索之前我应该​​联系社区。

# Source | https://matplotlib.org/gallery/pie_and_polar_charts/polar_scatter.html
# Fixing random state for reproducibility
np.random.seed(19680801)

# Compute areas and colors
N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2
colors = theta

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python matplotlib cartesian

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

Angular Kendo:布尔值的 kendo-grid-column 过滤器标签

我们正在使用 Angular Kendo,并且在我们正在渲染的表格(网格)之一中,标题是可过滤的。其中一列绑定到布尔字段,但我们希望显示适当的字符串而不是原始布尔值(即 active 与 true)。每行中实际属性的显示很容易通过条件(即{{ boolean-property ? "label 1" : "label 2"}})来处理,但标签有点棘手。现在,过滤器的外观如下:

在此输入图像描述

我的目标是用更合适的东西更新标签,我检查了文档,我能找到的最接近的是格式属性,我不确定它如何适用于布尔值。

有谁知道如何设置过滤器菜单的标签?

label filter kendo-ui kendo-grid angular

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

Python 3:如何向线程池提交异步函数?

我想同时使用ThreadPoolExecutorfromconcurrent.futures和 async 函数。

我的程序反复向线程池提交具有不同输入值的函数。在那个更大的函数中执行的最终任务序列可以是任何顺序,我不关心返回值,只关心它们在未来的某个时刻执行。

所以我尝试这样做

async def startLoop():

    while 1:
        for item in clients:
            arrayOfFutures.append(await config.threadPool.submit(threadWork, obj))

        wait(arrayOfFutures, timeout=None, return_when=ALL_COMPLETED)
Run Code Online (Sandbox Code Playgroud)

提交的函数是:

async def threadWork(obj):
   bool = do_something() # needs to execute before next functions
   if bool:
       do_a() # can be executed at any time
       do_b() # ^
Run Code Online (Sandbox Code Playgroud)

wheredo_bdo_ais async 函数。问题是我收到错误:TypeError: object Future can't be used in 'await' expression如果我删除等待,我会收到另一个错误,提示我需要添加await.

我想我可以让一切都使用线程,但我真的不想那样做。

python multithreading asynchronous python-3.x python-asyncio

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

为什么validation_freq不能与Keras模型配合使用?

根据Keras 文档,fit 需要一个validation_freq参数:

validation_freq:仅在提供验证数据时相关。整数或列表/元组/集合。如果是整数,则指定在执行新的验证运行之前要运行多少个训练纪元,例如,validation_freq=2 每 2 个纪元运行验证。如果列表、元组或集合指定要运行验证的时期,例如,validation_freq=[1,2,10] 在第 1、2 和 10 时期结束时运行验证。

result = model.fit( X_train, Y_train, epochs=2000, verbose=1, validation_data=(X_test,Y_test), validation_freq=10) # , validation_split=0.2
Run Code Online (Sandbox Code Playgroud)

这引发了:

File "/Users/george/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 942, in fit
raise TypeError('Unrecognized keyword arguments: ' + str(kwargs))
TypeError: Unrecognized keyword arguments: {'validation_freq': 10}
Run Code Online (Sandbox Code Playgroud)

使用Keras2.1.6-tf。此后是否已添加此参数?

如果是这样,如何为 Anaconda 更新 Keras?我试过:

> conda update keras
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.
Run Code Online (Sandbox Code Playgroud)

python anaconda keras tensorflow

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

拆分并提取R中字符串的一部分(在"."和数字之间)

我有一个字符变量(companies),其观察结果如下所示:

  1. "612. Grt.Am.Dgt.&Inv.7.33"
  2. "77. Wickes 4.61"
  3. "265. Wang Labs 8.75"
  4. "9. CrossLand Savings 6.32"
  5. "228. JPS Textile Group 2.00"

我试图将这些字符串分成3部分:

  1. 第一个之前的所有数字".",
  2. 第一个"."和下一个数字之间的所有内容(格式一致#.##),以及
  3. 最后一个数字本身(格式#.##).

以第一个障碍为例,我想:"612","Grt.Am.CMt&Inv","5.01"

我尝试过定义模式rebus并使用str_match,但下面的代码仅适用于像obs#2和#3这样的情况.它并不反映字符串中间部分的所有变化以捕获其他障碍物.

pattern2 <- capture(one_or_more(DGT)) %R% DOT %R% SPC %R% 
            capture(or(one_or_more(WRD), one_or_more(WRD) %R% SPC 
            %R% one_or_more(WRD))) %R% SPC %R% capture(DGT %R% DOT 
            %R% one_or_more(DGT))

str_match(companies, pattern = pattern2)
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法将字符串分成这3个部分?

我不熟悉regex,但我已经看到了很多建议(我是R和Stack Overflow的新手)

regex r stringr

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

Android Alarm Manager不适用于Flutter Project App

我在New Flutter应用程序中安装了Android Alarm Manager插件.我使用插件的示例代码 - 但它在控制台中出错.

请建议如何使android报警管理器插件工作.如何将Dart的android_alarm_manager集成到应用程序中,以便用户在计划中选择的时间到达时会收到警报?

我使用此链接中的代码:https: //github.com/flutter/plugins/tree/master/packages/android_alarm_manager

 //////  main.dart://///////

    import 'dart:isolate';
    import 'package:android_alarm_manager/android_alarm_manager.dart';
    import 'package:flutter/material.dart';

    void printHello() {
      final DateTime now = DateTime.now();
      final int isolateId = Isolate.current.hashCode;
      print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
    }
    void main() async {
      final int helloAlarmID = 0;
      await AndroidAlarmManager.initialize();
      runApp(MaterialApp(home: Application()));
      await AndroidAlarmManager.periodic(const Duration(minutes: 1), helloAlarmID, printHello);
    }
    class Application extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Container(),
        );
      }
    }


///////////////Application.java/////////////////////

    package io.flutter.plugins.androidalarmmanagerexample;
    import io.flutter.app.FlutterApplication; …
Run Code Online (Sandbox Code Playgroud)

android alarmmanager dart flutter

12
推荐指数
2
解决办法
3247
查看次数

Vuex-多次调度后运行功能

我正在创建一个应用程序,并在某个时候需要加载一些数据,但是为了让用户看不到损坏的数据,我正在插入一个加载组件。

目前,我将setTimeout放入了负载中,但是在某些时候,API响应可能会花费超过1秒的时间。因此,我只想在所有调度完成后才更新加载状态。

MainComponent.vue

beforeCreate() {
    this.$store.dispatch('responsibles/fetchData')
    this.$store.dispatch('events/fetchData')
    this.$store.dispatch('wallets/fetchData')

    // Need to run this setTimeout after all the above dispatches become completed...
    setTimeout(() => {
        this.loading = false
    }, 1000)
}
Run Code Online (Sandbox Code Playgroud)

store/modules/responsibles.js

const state = {
    responsibles: []
}

const actions = {
    fetchData({dispatch}) {
        function getresponsibles() {
            return http.get('responsibles')
        }

        axios.all([
            getresponsibles()
        ]).then(axios.spread(function (responsibles) {
            dispatch('setResponsibles', responsibles.data.data)
        })).catch(error => console.error(error))
    },
    setResponsibles({commit}, responsibles) {
        commit('SET_RESPONSIBLES', responsibles)
    }
}

const mutations = {
    SET_RESPONSIBLES(state, responsibles) {
        state.responsibles = responsibles
    }
} …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuex vue-cli-3

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