小编And*_*ter的帖子

如何在nuxt js中使用vuetify作为插件?

我需要在我的 nuxt js 项目中使用 vuetify 作为插件。我试过包@nuxtjs/vuetify但得到错误

无法分配给对象“#”的只读属性“base”

在此处输入图片说明

我已经在本地服务器和共享主机上从官方代码盒子在线游乐场安装了我的 nuxt 项目。我一直都遇到同样的错误。我尝试使用npm和安装节点模块yarn。如何使用 npm 包vuetify将新的 vuetify 版本作为插件添加到最新版本的 nuxt js 中?

node.js vue.js vuejs2 nuxt.js vuetify.js

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

如何在 Nuxt.js 中使用官方 Swiper.js 作为插件

我有swiper.js带有代码的插件:

import Vue from "vue";
// import Swiper core and required components
import SwiperCore, { Navigation, Pagination, Scrollbar, A11y } from "swiper";

// Import Swiper Vue.js components
import { Swiper, SwiperSlide } from "swiper/vue";

// Import Swiper styles
import "swiper/swiper.scss";
import "swiper/components/navigation/navigation.scss";
import "swiper/components/pagination/pagination.scss";
import "swiper/components/scrollbar/scrollbar.scss";

// install Swiper components
SwiperCore.use([Navigation, Pagination, Scrollbar, A11y]);
Vue.use(Swiper, SwiperCore, SwiperSlide);
Run Code Online (Sandbox Code Playgroud)

但这对我来说不起作用。在这里你可以看到我在CodeSandbox上的完整演示代码

我尝试从Vue.js 的官方文档安装 Swiper

依赖关系

"dependencies": {
  "core-js": "^3.6.5",
  "nuxt": "^2.14.6",
  "swiper": "^6.3.2"
},
"devDependencies": {
  "@nuxtjs/style-resources": "^1.0.0", …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js nuxt.js swiper.js

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

Nuxt 3 包导入说明符“#internal/ninto”未定义

我尝试使用命令安装新版本的Nuxt.js

npx nuxi init nuxt-app
Run Code Online (Sandbox Code Playgroud)

然后尝试在 Nuxt 3 中运行和项目工作正常。但是当我尝试运行这个命令时:

npm run generate
Run Code Online (Sandbox Code Playgroud)

获取此错误消息:

错误[nuxt] [请求错误]从 C:\Users\Andreas\Projects\nuxt3 导入的包 C:\Users\Andreas\Projects\nuxt3-app\package.json 中未定义包导入说明符“#internal/nitro” -app.nuxt\dist\server\server.mjs 在新的 NodeError (node:internal/errors:371:5) 在 throwImportNotDefined (node:internal/modules/esm/resolve:442:9) 在 packageImportsResolve (node:internal/模块/esm/resolve:819:3) 在 moduleResolve (节点:internal/modules/esm/resolve:973:21) 在 defaultResolve (节点:internal/modules/esm/resolve:1080:11) 在 ESMLoader.resolve (节点:internal/modules/esm/loader:530:30) 在 ESMLoader.getModuleJob (节点:internal/modules/esm/loader:251:18) 在 ModuleWrap。(节点:内部/模块/esm/module_job:79:40)在链接(节点:内部/模块/esm/module_job:78:36)

我的package.json源代码:

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "nuxt": "3.0.0-rc.1"
  }
}
Run Code Online (Sandbox Code Playgroud)
  • 节点版本:16.14.1
  • NPM版本:8.5.0

javascript node.js vue.js nuxt.js nuxtjs3

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

如何使用正则表达式在Laravel中路由前缀?

简要:

我有一个带有动态前缀的自定义路由组:

Route::prefix('{nickname}')->group(function () {
    Route::get('/', function($nickname) {
        return view('profile');
    })->where(['nickname' => '[a-z]+']);

    Route::get('/edit', function($nickname) {
        return view('profile.edit');
    })->where(['nickname' => '[a-z]+']);
});
Run Code Online (Sandbox Code Playgroud)

如您所见,在每条路线上,我通过正则表达式检查前缀的正确性.

注意:我也习惯->where(['nickname' => '[a-z]+'])路由组并出错.

错误信息:

调用一个成员函数where()on null

题:

如何只检查一次才能解决问题?

routing routes laravel laravel-routing laravel-5.7

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

Laravel:查询返回错误结果

我有自定义代码来获得空缺:

Laravel雄辩的查询:

$vacancy = new Vacancy;
$vacancy = $vacancy->has('user')->orWhere('is_express', 1);
$where = [];
$date = Carbon::now()->subDays(10);
$where[] = ['deleted_at', null];
$where[] = ['updated_at', '>=', $date];
$employment = [0];
$vacancy = $vacancy->whereIn('employment', $employment);
$vacancy = $vacancy->where($where)->get();
Run Code Online (Sandbox Code Playgroud)

SQL代码:

select * from `vacancies`
where(exists(select * from `users`
    where `vacancies`.
    `user_id` = `users`.
    `id`
    and `users`.
    `deleted_at`
    is null) or `is_express` = 1 and `employment` in ( 0 ) and(`deleted_at`
    is null and `updated_at` >= '2019-03-22 08:48:34' )) and `vacancies`.
`deleted_at`
is null
Run Code Online (Sandbox Code Playgroud)

这 …

mysql sql laravel eloquent

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

将 args 传递给 laravel eloquent api 资源构造函数

如何将参数传递给 Laravel Eloquent API 资源构造函数并使其返回响应时的​​条件数据?

我尝试过的:

控制器

$user = User::find(1);
return new UserResource($user, $shortData = true);
Run Code Online (Sandbox Code Playgroud)

API资源:

public function toArray($request, $shortData)
{
    if($short) {
        return $shortData;
    } else {
        return $fullData;
    }
}
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-6

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

Laravel Eloquent API 资源:从响应(集合)中删除“数据”键

我有 Eloquent API Resource UserResource。当我尝试运行这样的代码时:

$users = User::paginate(10);
return UserResource::collection($users);
Run Code Online (Sandbox Code Playgroud)

响应将是这样的:

{
    "data": [
        {
            "name": "Fatima Conroy",
            "email": "ocie.stark@example.org"
        },
        {
            "name": "John Doe",
            "email": "john.doe@example.org"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

如何删除data密钥或重命名它以获得类似此响应的内容?

[
    {
        "name": "Fatima Conroy",
        "email": "ocie.stark@example.org"
    },
    {
        "name": "John Doe",
        "email": "john.doe@example.org"
    }
]
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-eloquent-resource laravel-7

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

Ngnix laravel docker项目返回错误502 bad gateway

我尝试使用 ngnix 在 docker 容器内运行 laravel。

目录结构:

在此输入图像描述

文件docker-compose.yml

version: '3'
services:
    nginx:
      image: nginx:stable-alpine
      container_name: nginx
      ports:
        - "${HOST_PORT}:80"
      volumes:
        - ../:/var/www/html
        - ./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf
      depends_on:
        - php
    php:
        build:
          context: .
          dockerfile: ../Dockerfile
        restart: always
        container_name: php
        volumes:
            - "../:/var/www/html"
        ports:
          - "9000:9000"
    mongodb:
        image: mongo:latest
        container_name: mongodb
        ports:
            - "27017:27017"
    redis:
        image: redis:latest
        container_name: redis
        restart: always
        ports:
            - "6379:6379"
Run Code Online (Sandbox Code Playgroud)

文件Dockerfile

FROM php:7.4-apache

RUN apt-get update && apt-get install --yes --no-install-recommends \
    libssl-dev

RUN docker-php-ext-install …
Run Code Online (Sandbox Code Playgroud)

nginx laravel docker docker-compose nginx-config

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

Laravel:为什么我的ajax请求返回"500(内部服务器错误)"?

我正在尝试使用Laravel 5.5中的按钮发出AJAX请求.控制台返回POST:500(内部服务器错误).

在此输入图像描述

我在这里的Javascript代码:

<script type="text/javascript">
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $('#insertForm').on('submit', function(e){
        e.preventDefault();
        var data = $(this).serialize();
        var url  = $(this).attr('action');
        var post = $(this).attr('method');

        $.ajax({
             type: post,
             url: url,
             data: data,
             dataType: 'json',
          success:function(data)
          {
            console.log(data)
          }
        })          
    })
</script>
Run Code Online (Sandbox Code Playgroud)

我的HTML表单代码:

<form action="{{ URL::to('add') }}" class="translation-form" method="POST" id="insertForm">
        <div class="language-area">
            <textarea class="form-control wow fadeIn" data-wow-duration="0.5s" name="words" id="lang-input" rows="10"></textarea>
        </div>
            <p class="upload-info wow fadeInDown" data-wow-duration="0.5s" data-wow-delay="0.3s">
            Add words from file
            <input type="file" name="file-1" id="file-1" class="inputfile inputfile-1" data-multiple-caption="{count} files …
Run Code Online (Sandbox Code Playgroud)

php ajax request laravel laravel-5.5

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

Javascript从字符串键解析对象键值

我有自定义对象

var user = {
  name: "John",
  lastname: "Doe",
  details: {
    age: 33,
    gender: "male",
    education: {
      university: "Oxford"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

现在我需要一个可以从字符串中解析对象键的函数。例如函数参数:

getObjectKeyValue("details.age") // 33
getObjectKeyValue("details.education.university") // Oxford
Run Code Online (Sandbox Code Playgroud)

如何实现像这样的函数,从基于字符串点的键中获取对象键值?

javascript

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