小编use*_*891的帖子

反应 js 项目中未出现 Bootstrap 图标

我使用以下命令创建了一个反应项目:

npx create-react-app project
Run Code Online (Sandbox Code Playgroud)

我已经使用 npm 命令安装了 bootstrap 4.3.1 并且我也已经将 bootstrap 导入到 index.js 文件中

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,它没有显示图标。

export class Navbar extends Component {
    render() {
        return (
            <div>
                <nav className="navbar navbar-light bg-dark mb-5">
                    <div className="container">
                        <div className="navbar-header">
                            <a className="navbar-brand text-white text-lg brand-text" to="/">
                                MovieSeriesInfo</a>
                        </div>
                        <ul className="navbar-nav ml-auto text-light d-inline-block">
                            <li className="nav-item d-inline-block mr-4">
                                <i className="fab fa-imdb fa-5x" id="imdb-logo" />
                            </li>
                            <li …
Run Code Online (Sandbox Code Playgroud)

reactjs bootstrap-4

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

如何将请求传递给DTO进行断言验证?

我正在努力实现symfony validation asset该要求。

我正在form-data从邮递员传递到控制器中的路线。

#[Route(path: '/test', name: 'test', methods: 'GET')]
    public function login(LoginRequest $loginRequest): Response
Run Code Online (Sandbox Code Playgroud)

我创建了一个loginRequestDTO,如下所示:

class LoginRequest
{
    public function __construct(
        /**
         * @Assert\NotBlank
         */
        public string $username,
        /**
         * @Assert\NotBlank
         */
        public string $password
    ) {
    }
}
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误。

Cannot autowire service "App\Dto\LoginRequest": argument "$username" of method "__construct()" is type-hinted "string", you should configure its value explicitly.
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我如何使用 DTO 来验证参数请求吗?

symfony symfony5

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

如何为查询添加分页?

在我做一个选择某个字段和一些条件的查询之前.这行代码给了我正确的结果.

public function index()
{
    // Get links
    $links = Link::select('id', 'url', 'short_url', 'counter', 'expired_on')
        ->orderBy('id', 'desc')
        ->where('delete_flg', 0)
        ->get();

    // Return data
    return view('dashboard')->with(
        array(
            'links' => json_decode($links),
            'current_datetime' => Carbon::now()
        )
    );
}
Run Code Online (Sandbox Code Playgroud)

现在我想对上面的行实现分页.

$links = Link::select('id', 'url', 'short_url', 'counter', 'expired_on')
    ->orderBy('id', 'desc')
    ->where('delete_flg', 0)
    ->get()->paginate(2);
Run Code Online (Sandbox Code Playgroud)

当我尝试在最后使用paginate(2)时,我得到错误:

Method Illuminate\Database\Eloquent\Collection::paginate does not exist.
Run Code Online (Sandbox Code Playgroud)

所以从其他一些教程我尝试没有 - > get()然后paginate然后我得到这样的错误.

count(): Parameter must be an array or an object that implements Countable
Run Code Online (Sandbox Code Playgroud)

我对如何实现paginate很困惑.

有人可以帮帮我吗?

php laravel laravel-5.6

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

标签 统计

bootstrap-4 ×1

laravel ×1

laravel-5.6 ×1

php ×1

reactjs ×1

symfony ×1

symfony5 ×1