小编Sha*_*ath的帖子

解决Laravel迁移文件的此错误:每个类必须位于至少一个级别的名称空间中

如何解决此phpcs错误?它会Keyword在所有Laravel迁移文件中显示该类。错误消息是:

每个类都必须在至少一个级别(顶级供应商名称)phpcs的命名空间中

在此处输入图片说明

laravel phpcs

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

node.js中的异步等待在节点v8.1.0中不起作用

我正在尝试刷新Redis缓存数据库并在响应中返回状态。但是在清除缓存之前,它会返回响应。

在下面的代码中,由于不等待flushRedisDB,console.log将始终显示未定义的内容。

我的节点版本是v8.1.0

myfile.js

async function flushRedisapi(request, response)
{
    try {
        var value = await redisModules.flushRedisDB();
        console.log("the value is : " + value);
        if(value)
            response.status(200).send({status : 'Redis Cache Cleared'});
        else
            response.status(400).send({status : "Redis Cache could not be flushed"});

    } catch (error) {
        response.status(400).send({status : "Redis Cache could not be flushed"});
    }
}
Run Code Online (Sandbox Code Playgroud)

redismodule.js

var redisClient;        // Global (Avoids Duplicate Connections)

module.exports = 
{
    openRedisConnection : function()
    {
        if (redisClient == null) 
        {
            redisClient = require("redis").createClient(6379, 'localhost');
            redisClient.selected_db = 1;
        } …
Run Code Online (Sandbox Code Playgroud)

asynchronous node.js async-await

3
推荐指数
2
解决办法
8593
查看次数

更改分页选择/活动项目背景颜色

我正在使用此控件进行分页链接并能够得到以下结果。

在此输入图像描述

我可以更改非选定/活动项目的背景颜色,但如何更改选定项目的样式,如上图 8 所示,它是紫色的,所以我需要它是不同的颜色。

下面是react中的JS代码

const styles = theme => ({
    paginationItemStyle: {
        marginLeft: "5px",
        color: "white"
    },
    paginationLinkStyle: {
        backgroundColor: "#b90000",
        borderRadius: "5px",

        "&:hover": {
            backgroundColor: "#772e2e",
        },

        "&:active": {
            backgroundColor: "#772e2e",
        }
    }
});


<Pagination>

    <PaginationItem>
        <PaginationLink previous />
    </PaginationItem>

    {someNumbersList.map((i, key) => (
    <PaginationItem key={key} className={classes.paginationItemStyle} active={currentPage==(i+1)}>
        <PaginationLink className={classes.paginationLinkStyle}>
            {i+1}
        </PaginationLink>
    </PaginationItem>
    ))}

    <PaginationItem>
        <PaginationLink next />
    </PaginationItem>

</Pagination>
Run Code Online (Sandbox Code Playgroud)

reactjs react-bootstrap reactstrap

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

未捕获的 ReferenceError:regeneratorRuntime 未在 react 17、webpack 5 中定义,同时通过操作进行 api 调用

Uncaught ReferenceError: regeneratorRuntime is not defined尝试使用超级代理进行 api 调用时出现此错误。

目前我正在使用 react 17、webpack 5 以及 css 模块和所有最新的包。

包.json

{
  "dependencies": {
    "date-fns": "^2.16.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.2",
    "react-router-dom": "^5.2.0",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "superagent": "^6.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/preset-env": "^7.12.11",
    "@babel/preset-react": "^7.12.10",
    "@dr.pogodin/babel-plugin-react-css-modules": "^6.0.10",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.2.2",
    "css-loader": "^5.0.1",
    "eslint": "^7.16.0",
    "html-webpack-plugin": "^5.0.0-beta.1",
    "mini-css-extract-plugin": "^1.3.3",
    "node-sass": "^5.0.0",
    "postcss": "^8.2.1",
    "postcss-scss": "^3.0.4",
    "sass": "^1.30.0",
    "sass-loader": "^10.1.0",
    "style-loader": "^2.0.0",
    "url-loader": "^4.1.1",
    "webpack": "^5.11.0",
    "webpack-cli": "^4.3.0",
    "webpack-dev-server": "^3.11.0"
  } …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs webpack babeljs babel-loader

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

Node.js异步模块在迭代完成之前完成

我有大约100个Rss链接需要每3分钟获取一次.

所以我使用异步模块来做到这一点.但在处理完所有Rss链接之前,它就会完成并退出.以下是代码.

feedRecords是一个包含RSS url和id 的数组;

var items = [];
var parseRss = require("parse-rss");
var async = require('async');

async.forEach(feedRecords, function taskIterator(feedItem, callback) 
{
    parseRss(feedItem.url, function (err, articles) 
    {
        if (err) 
        {
            callback(err);
        }
        else 
        {
            console.log("Feed Id : " + feedItem.feed_id + ", Length : " + articles.length);
            items.push({ data : articles, feed_id : feedItem.feed_id });
            callback(null);
        }
    });
},
function ()
{
    if (items.length > 0) 
    {
        console.log("Total : " + items.length);
    }
    else
        console.log("No data found"); …
Run Code Online (Sandbox Code Playgroud)

javascript rss asynchronous feed node.js

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

CSS中的加号

我有下面的CSS代码,该代码给出+符号,但与设计基本不匹配,因此需要变薄。参见摘要鳕鱼

.plus {
  position:relative;
  border: 1px dotted white;
  width: 3px;
  height: 3px;
  background-color: black;
  box-sizing: border-box;
  transform: scale(11);
}
Run Code Online (Sandbox Code Playgroud)
<div class="plus"></div>
Run Code Online (Sandbox Code Playgroud)

应该看起来像下面的符号: CSS中的加号

Any other styling is also fine for me but should look like the snapshot.

html css css-shapes

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

在Laravel DB select函数中从MySql获取特定列值

如何在Laravel DB select函数中从MySql获取结果后获取特定的列值

下面是我的PHP代码.

$list = DB::select('SELECT DISTINCT a.pincode FROM table_name nvs 
        JOIN areas a on nvs.area_id = a.id 
        where nvs.city_id = ?;', [$area_id]);
Run Code Online (Sandbox Code Playgroud)

以下是上述查询的结果.

[
  {
    "pincode": "560005"
  },
  {
    "pincode": "560006"
  }
]
Run Code Online (Sandbox Code Playgroud)

我只需要pincode值而不是键值对.所以我尝试使用以下代码.

return array_column($list->toArray(), 'pincode');
Run Code Online (Sandbox Code Playgroud)

在数组上调用成员函数toArray().

如何在不使用foreach循环的情况下仅获取值.

回答

我使用下面的代码

$pincode_list = DB::table('table_name as nvs')
            ->join('areas as a', 'nvs.area_id', '=', 'a.id')
            ->select('a.pincode')
            ->where('nvs.city_id', '=', $area_id)
            ->distinct('a.pincode')->pluck('pincode')->toArray();
Run Code Online (Sandbox Code Playgroud)

结果是:

[
    "560067",
    "560035"
]
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.3

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

如何在react.js中的Material UI中更改DialogTitle和DialogContent中的字体颜色

如何在React.js的 Material UI中更改DialogTitleDialogContent中的字体/文本颜色

更改Dialog的背景颜色可以,但是尝试更改Dialog和DialogContent的字体颜色不起作用。

<Dialog
    open={this.state.open}
    aria-labelledby="alert-dialog-title"
    aria-describedby="alert-dialog-description"
    PaperProps={{
       style: {
           backgroundColor: "#fff",
       },
    }}
    >

    <DialogTitle id="alert-dialog-title">
         "Use Google's location service?"
    </DialogTitle>

    <DialogContent>
         <DialogContentText id="alert-dialog-description">
              Hello 
         </DialogContentText>
    </DialogContent>

    <DialogActions>
         <Button onClick={this.handleClose} color="primary">
                OK
         </Button>
    </DialogActions>
</Dialog>
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

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