小编Ala*_*ene的帖子

使用lodash删除对象属性

我必须删除与我的模型不匹配的不需要的对象属性.我怎么能用lodash实现它.

我的模型是

var model = {
   fname:null,
   lname:null
}
Run Code Online (Sandbox Code Playgroud)

在发送到服务器之前我的控制器输出将是

var credentials = {
    fname:"xyz",
    lname:"abc",
    age:23
}
Run Code Online (Sandbox Code Playgroud)

如果我使用

 _.extend (model, credentials)
Run Code Online (Sandbox Code Playgroud)

我也正在获得年龄的财产.我知道我可以使用

delete credentials.age
Run Code Online (Sandbox Code Playgroud)

但如果我有超过10个不需要的对象怎么办?我可以用lodash实现它吗?

lodash

51
推荐指数
4
解决办法
8万
查看次数

角材料网格系统

我对角材料设计材料css感到困惑.为什么两者都有不同的布局和网格?角材料设计中 bootstrap容器的等价物是什么?

与引导程序相比,我应该为我的项目使用角度材料设计吗?

angularjs material-design

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

Laravel 从存储中检索图像以查看

我使用下面的代码来存储上传的文件

 $file = $request->file($file_attachment);
        $rules = [];
        $rules[$file_attachment] = 'required|mimes:jpeg|max:500';
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) {
            return redirect()->back()
                ->with('uploadErrors', $validator->errors());
        }

        $userid = session()->get('user')->id;
        $destinationPath = config('app.filesDestinationPath') . '/' . $userid . '/';
        $uploaded = Storage::put($destinationPath . $file_attachment . '.' . $file->getClientOriginalExtension(), file_get_contents($file->getRealPath()));
Run Code Online (Sandbox Code Playgroud)

上传的文件存放在storage/app/2/filename.jpg

我想向用户展示他上传的文件。我怎样才能做到这一点?

$storage = Storage::get('/2/filename.jpg');

我收到无法阅读的文本。我可以确认文件已被读取。但是如何将其作为图像显示给用户。

希望我说清楚了。

工作解决方案

display.blade.php

<img src="{{ URL::asset('storage/photo.jpg') }}" />
Run Code Online (Sandbox Code Playgroud)

网页.php

Route::group(['middleware' => ['web']], function () {
    Route::get('storage/{filename}', function ($filename) {
        $userid = session()->get('user')->id;
        return Storage::get($userid . '/' . $filename);
    }); …
Run Code Online (Sandbox Code Playgroud)

laravel

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

如何在 Firebase 托管上部署 Express 应用程序

我已经构建了一个快速应用程序,文件夹结构如下。

如下

然后我在一个虚拟文件夹上创建了 firebase init 托管并复制了 firebase.json 和 .firebase 文件

我创建了index.js文件

    const functions = require('firebase-functions')
    const app = require('./app');
    exports.widgets = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)

firebase.json

{
  "hosting": {
    "public": "public",
    "rewrite":[{
      "source": "**",
      "function": "widgets"
    }],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

还将 firebase 生成的 index.html 复制到 public 文件夹

在此处输入图片说明

在部署我得到 index.html

在此处输入图片说明

如果我删除 index.html 并作为 localhost 运行,我将低于输出

在此处输入图片说明

我如何在 firebase 部署上执行快速应用程序(如本地主机中所示)而不是 index.html。

编辑 1

我正在关注链接

当我运行firebase serve时,出现此错误

AssertionError [ERR_ASSERTION]: missing path at Module.require (module.js:583:3) at require (internal/module.js:11:18) …
Run Code Online (Sandbox Code Playgroud)

express firebase firebase-hosting google-cloud-functions

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

如何在 laravel 9 中使用 jQuery UI 和 vite

我正在学习 vite,并对将 jquery-ui 包含到项目中感到震惊。

库.ts

import * as jQuery from 'jquery';
declare global {
    interface Window {
        jQuery: typeof jQuery;
        $: typeof jQuery;
    }
}


window.$ = window.jQuery = jQuery;
require('jquery-ui-dist');
Run Code Online (Sandbox Code Playgroud)

主要.ts

jQuery(function(){
  console.log("i am called")  // getting console output
  jQuery(".datepicker").datepicker(); // getting error in editor  Property 'datepicker' does not exist on type 'JQuery<HTMLElement>'
});
Run Code Online (Sandbox Code Playgroud)

控制台输出 控制台输出

vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { esbuildCommonjs } from '@originjs/vite-plugin-commonjs'

export default defineConfig({
    plugins: [
        laravel({
            input: …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-ui laravel

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

Restangular删除身体数据

下面是我的restangular删除请求,我打算根据用户选择传递一组id来删除

var deleteIds = [1,5,10]
Restangular.all('url').customDELETE(deleteIds);
Run Code Online (Sandbox Code Playgroud)

我希望这个deleteIds在body params中传递.我如何将数组作为主体发送,以便我可以看到请求有效负载.

angularjs restangular

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

为什么我应该使用 JWT 而不是简单的哈希令牌

如果不共享敏感信息,还需要 JWT 做什么?

我可以创建一个令牌列,将其存储在数据库中并恢复它,以交叉验证令牌,然后获取用户详细信息。

自定义生成的令牌可以使用密钥进行哈希处理,因此不会被解码。既然如此简单,为什么要使用复杂的、有信息的 JWT 类型呢?

php jwt

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

在生产模式下运行 vite 时出现“jQuery 不是函数”

我正在尝试将 jQuery 与 laravel 9 + vite 一起使用。它在开发中工作正常,但在构建时,我发现 jQuery 不是一个函数

库.ts

import * as jQuery from 'jquery';
declare global {
    interface Window {
        jQuery: typeof jQuery;
        $: typeof jQuery;
    }
}

window.$ = window.jQuery = jQuery;
Run Code Online (Sandbox Code Playgroud)

主要.ts

jQuery(function(){
     console.log(jQuery(".datepicker"));
});
Run Code Online (Sandbox Code Playgroud)

vite.config.ts

jQuery(function(){
     console.log(jQuery(".datepicker"));
});
Run Code Online (Sandbox Code Playgroud)

npm run dev 的输出

npm run dev 的输出

npm run build 的输出

npm run build 的输出

jquery rollupjs vite laravel-9

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

带有angularjs 1.4到期日的$ cookies

如何使用angularjs 1.4设置有效期限的cookie.文档说要使用

expires - {string|Date} - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object indicating the exact date/time this cookie will expire.
Run Code Online (Sandbox Code Playgroud)

但是它不起作用.我的firebug只将会话日期显示为Session.

HTML

<div ng-app="cookieApp" ng-controller="cookieCtrl">
    <button ng-click="setCookie()">Set Cookie</button>
     <button ng-click="getCookie()">Get Cookie</button>
</div>
Run Code Online (Sandbox Code Playgroud)

使用Javascript

    var app=angular.module("cookieApp",['ngCookies']);
app.controller("cookieCtrl",function($scope, $cookies){
    $scope.setCookie = function(){
    console.log("setCookie");
        var now = new Date();
        now.setDate(now.getDate() + 7);
          $cookies.put("tech","angularjs",{expiry:now});
     }
     $scope.getCookie = function(){
          alert( $cookies.get("tech"));
    }
});
Run Code Online (Sandbox Code Playgroud)

我试图设置jsFiddle但我无法保存它.我的警报显示未定义.

cookies angularjs angular-cookies

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

Express-Session 未在生产中持续存在

我正在尝试在 gcloud 生产上运行我的 nodejs 应用程序,但快速会话未按预期工作。它在我本地的开发人员中运行良好。

应用程序.js

var express = require('express');

var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');

// var http = require('http');
// var reload = require('reload');


var index = require('./routes/index');
var users = require('./routes/users');
var user = require('./routes/user');
var dashboard = require('./routes/dashboard');
var search = require('./routes/search');
var profile = require('./routes/profile');
var ajax = require('./routes/admin-ajax');
var logout = require('./routes/logout');
var administrator = require('./routes/administrator'); …
Run Code Online (Sandbox Code Playgroud)

session node.js express gcloud

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

Flexbox垂直和水平中心,带有引导类

我正在尝试垂直对齐我的登录屏幕.这是我在JS Fiddle的代码并使用了css

.flexbox-container {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -ms-flex-align: center;
    -webkit-align-items: center;
    -webkit-box-align: center;.
    align-items: center;
}
Run Code Online (Sandbox Code Playgroud)

我没有让我的物品垂直居中.我将无法实现它,因为我使用bootstrap类到水平中心.

css flexbox twitter-bootstrap

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

$ state.go不是从单独的控制器工作

这是我的代码

$stateProvider
.state('home', {
url: "/home",
templateUrl: "views/home.tpl.html",
controller:"homeController"
})
.state('test', {
url: '/test',
templateUrl: "views/test/dashboard.tpl.html",

});
Run Code Online (Sandbox Code Playgroud)

我在index.html页面中的模态视图是

<div class="modal-body" ng-controller="userController">
    <form ng-submit="login()" >
        <div class="form-group">
        <label for="exampleInputEmail1">Email address</label>
        <input type="text" class="form-control" id="exampleInputEmail1" ng-model="user.email" placeholder="Enter email">
        </div>
        <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" class="form-control" id="exampleInputPassword1" ng-model="user.password" placeholder="Password">
        </div>
        <button type="submit" class="btn btn-default">Sign In</button>
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

我的userController函数是

$scope.login = function(){

     console.log($scope.user);
     if($scope.user.email=="xxxx" && $scope.user.password=="123456"){

         $state.go("test");


     }

 }
Run Code Online (Sandbox Code Playgroud)

Angular js正在抛出错误

TypeError:undefined不是l. $ scope.login(http://localhost/yyy/scripts/controllers/userController.js:15:19)的函数,位于ib.functionCall

国家没有转移.请让我知道我错在哪里

angularjs angular-ui-router

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

使用循环进度条倒计时器

我创建了一个倒数计时器.我有一个圆形的边框.当计时器趋于零时,圆形边框应该以秒为单位递减颜色.

我创建了JSFIDDLE

HTML

<div class="outer">
    <button class="btn btn-default btn-timer">0.00</button>
</div>
Run Code Online (Sandbox Code Playgroud)

JS代码

var displayminutes;
var displayseconds;
var initializeTimer = 1.5 // enter in minutes
var minutesToSeconds = initializeTimer*60;

$("#document").ready(function(){
    setTime = getTime();
    $(".btn-timer").html(setTime[0]+":"+setTime[1])
});


$(".btn-timer").click(function(){
    var startCountDownTimer = setInterval(function(){
          minutesToSeconds = minutesToSeconds-1;
        var timer = getTime();
         $(".btn-timer").html(timer[0]+":"+timer[1]);
        if(minutesToSeconds == 0){
            clearInterval(startCountDownTimer);
            console.log("completed");
        }
      },1000)
});


function getTime(){

    displayminutes = Math.floor(minutesToSeconds/60);
    displayseconds = minutesToSeconds - (displayminutes*60);
    if(displayseconds < 10)
    {   
        displayseconds ="0"+displayseconds;
    }
     if(displayminutes < 10)
    {   
        displayminutes = "0"+displayminutes;
    }

    return …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery css3 css-shapes

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