小编Jig*_*hah的帖子

CodeIgniter3:为什么首先要设置$ _SERVER ['CI_ENV']?

我看到在他们的默认安装中,他们的index.php有这样的:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
Run Code Online (Sandbox Code Playgroud)

为什么会CI_ENV曾经已经在内部设置$_SERVER阵列?

php codeigniter-3

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

单击按钮时如何重定向本机?

当我点击按钮时,如何进入下一个反应原生屏幕?

这是我的代码

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Button,
} from 'react-native';
import Test from './android/components/Test'


export default class ReactTest extends Component {


  render() {

    return (

      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome click the button to register.
        </Text>
         <Button
                    style={styles.cancelButton} 
                    onPress={this.editUser}
                    title="Register"
                    color="#343434"
                    accessibilityLabel="Register a User."/>
      </View>


    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我是反应原生的新手.按下注册按钮时,我试图从一个屏幕导航到另一个屏幕.

react-native

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

如何从对象中破坏部分属性

例如,我有一个像这样的对象:

obj1 = {
     name: 'Bob',
     age:  20,
     career: 'teacher'
  }
Run Code Online (Sandbox Code Playgroud)

现在我需要复制其部分属性而不是所有属性.

obj2 = {
     name: '',
     age: '',
  }
Run Code Online (Sandbox Code Playgroud)

我知道我可以这样做obj2.name = obj1.name,如果需要复制许多属性,这将是冗长的.还有其他快速方法可以解决这个问题吗?我试过了

let {name: obj2.name, age: obj2.age} = obj1;

但是得到了错误.

javascript ecmascript-6

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

this.textInput.focus 不是一个函数 - React

I have FormControl for password input with icon that toggles the mask, so u cant see the characters you are inputting. But whenever I toggle this mask I also want to re-focus the input field.

<FormGroup
    className="input-text input-text--password"
    controlId={id}
    validationState={submitFailed && touched && error ? 'error' : validationState}
  >

    <FormControl
      {...input}
      disabled={disabled}
      className="input-text__input"
      autoFocus={autoFocus}
      type={maskEnabled ? 'password' : 'input'}
      onChange={this.handleFormControlChange}
      maxLength={maxLength}
      ref = { ref => this.textInput = ref }
    />
    <div
        className={'input-text__button ' + (maskEnabled ? 'mask-enabled' : 'mask-disabled')} …
Run Code Online (Sandbox Code Playgroud)

javascript jquery reactjs

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

文本的第二行不在行的中心呈现

我的 样式有问题Text,我有两行 ,Text文本的第一行在行的中心显示正确,但代码的第二行不在中心。如何解决?

<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
  <Text
    style={{ marginLeft: 5, fontWeight: '500', fontFamily: 'Arial', fontSize: ratio * 14, color: '#3c3c3c' }}
    numberOfLines={2} > {title}
  </Text>
</View>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

text react-native

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

如何在Laravel中将stdClass的对象转换为数组

尝试在Laravel中显示视图时出现下一个错误:

“不能将stdClass类型的对象用作数组(视图:C:\ xampp \ htdocs \ mysite \ resources \ views \ cms \ contactus.blade.php)”。

我的控制器:

public function contactus(){ 

    ContactUS::get_content(self::$data);
    return view('cms.contactus', self::$data); 

} 
Run Code Online (Sandbox Code Playgroud)

我的模特:

class ContactUS extends Model
{

public $table = 'contactus';

public $fillable = ['name','email','message']; 

static public function get_content(&$data){ 


        $sql = "SELECT cu.*,name,email,message FROM contactus cu "
            . "ORDER BY cu.created_at DESC ";

        $data['contactusd'] = DB::select($sql); 

     }

} 
Run Code Online (Sandbox Code Playgroud)

我的看法:

@extends ('cms.cms_master') 
@section('cms_content')
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <h1 class="page-header">Contact us form information</h1>
    @if($contactusd) 
    <br><br>
    <table class="table …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.3 laravel-5.4

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

返回多个变量以在laravel中查看的最佳方法

我有一个动作方法,它的体内有多个变量,如下所示: -

$bus=Bus::all();
$user=User::all();
$employer=employer::all();
Run Code Online (Sandbox Code Playgroud)

将这些变量对象返回到视图的做法是使用这样的代码

return view('create')->with(compact('bus', $bus))->with(compact('user', $user))->with(compact('employer', $employer));
Run Code Online (Sandbox Code Playgroud)

是否有一种方法可以立即返回此对象,而无需使用所有这些代码

return view('create')->($user,$bus,$emp);
Run Code Online (Sandbox Code Playgroud)

只是我想要的例子.

php laravel

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

AngularJS错误注入模块

我正在尝试使用cookie开发登录,检查用户是否已经登录.

按顺序,我包括应用程序:

angular.module('ELOAuthentication', [
    'AuthenticationService',
    'ngRoute',
    'ngCookies',
    'angular-loading-bar'
])
Run Code Online (Sandbox Code Playgroud)

然后是服务

angular.module('ELOAuthentication').factory('AuthenticationService', function ($rootScope, $scope, $http) {

    var service = {};

    service.Login = function (email, password, callback) {
        var Url = '/api/user/GetLoginByEmailPassword';

        $http.then(Url, { email: email, password: password }).success(
            function (response) {
                var data = response.data
                callback(data);
            }).catch(function (error) {
                console.log('ERROR GetLoginByEmailPassword: ' + error);
            });
    }

    service.SetCookie = function (email, password) {

    };

    service.ClearCookie = function () {

    };
});
Run Code Online (Sandbox Code Playgroud)

最后是AngularJS控制器.

angular.module('ELOAuthentication').controller('LoginController', function ($rootScope, $scope, $http) {

    AuthenticationService.ClearCookie();

    $scope.init = …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

Laravel 生成器给出:无法重新声明 generatorFunction()

我有以下代码,但是当我运行我的工厂时,出现以下异常:

无法在 /Users/user/Desktop/my-app/database/factories/QuestionFactory.php 中重新声明 questionIndex()(之前在 /Users/user/Desktop/my-app/database/factories/QuestionFactory.php:42 中声明)第 46 行

当我运行我的单元测试时会发生这种情况,而这个特定的工厂现在不在测试中。我有其他工厂有一个生成器,但函数的名称完全不同。被称为autoIncrement()

<?php

use Faker\Generator as Faker;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

$questionIndex = questionIndex();

$factory->define(App\Models\Question::class, function (Faker $faker, $overrides) use ($questionIndex) {

    $question = [
        'How is 2 + 2?',
        'Choose, what …
Run Code Online (Sandbox Code Playgroud)

php generator laravel

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

获取字符串内标签内的内容

这是我的字符串

var a ="<div id='render'>First<div class='render1'>Second</div></div>";
Run Code Online (Sandbox Code Playgroud)

我需要把里面的文字renderrender1

我怎样才能做到这一点 ?

我试过

var a ="<div id='render'>First<div class='render1'>Second</div></div>";
alert(a.getElementsByTagName("render")[0].innerHTML);
Run Code Online (Sandbox Code Playgroud)

这是我的小提琴

但我收到了类似的错误

未捕获的类型错误:a.getElementsByTagName 不是函数

我怎样才能做到这一点

笔记 :

这不是来自站点的内容,我试图从其他语句中获取文本,因此我将响应分配给一个变量并对其进行处理。

我只需要使用 javascript 来做到这一点

html javascript

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