小编Ral*_*thy的帖子

如何用Homebrew更新Ruby?

我想知道如何使用Homebrew 更新到最新的稳定版Ruby.我对使用RVM 感兴趣.谢谢.

ruby macos homebrew

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

何时使用禁用属性与HTML元素的aria-disabled属性?

我正在尝试使表格可访问.我应该让我的输入双双disabledaria-disabled属性,或只是一个?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" disabled>
Run Code Online (Sandbox Code Playgroud)

或者像这样?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-disabled="true">
Run Code Online (Sandbox Code Playgroud)

或者像这样?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-disabled="true" disabled>
Run Code Online (Sandbox Code Playgroud)

html html5 accessibility html-input wai-aria

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

何时使用必需属性与输入元素的aria-required属性?

我正在尝试使表格可访问.我应该让我的输入双双requiredaria-required属性,或只是一个?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" required>
Run Code Online (Sandbox Code Playgroud)

或者像这样?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-required="true">
Run Code Online (Sandbox Code Playgroud)

或者像这样?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-required="true" required>
Run Code Online (Sandbox Code Playgroud)

文章Accessible HTML5 Forms - Required Inputs声称最好同时实现这两者.

html5 accessibility html-input required wai-aria

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

打印/显示JavaScript变量的名称而不是它的值

是否可以打印/显示JavaScript变量的名称?例如:

var foo=5;
var bar=6;
var foobar=foo+bar;

document.write(foo+ "<br>");
document.write(bar+ "<br>");
document.write(foobar + "<br>");
Run Code Online (Sandbox Code Playgroud)

我们如何打印变量的名称,以便输出:

foo 
bar 
foobar
Run Code Online (Sandbox Code Playgroud)

而不是:

5
6
11
Run Code Online (Sandbox Code Playgroud)

javascript string variables type-conversion document.write

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

如何使用JavaScript向Mandrill发送电子邮件?

我已经按照指南关于如何使用Mandrill使用JavaScript发送电子邮件,但我在控制台中收到此错误:Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mandrillapp.com/api/1.0/messages/send.json. This can be fixed by moving the resource to the same domain or enabling CORS.

这是我的代码:

$('#submitEmail').click(function() {
  $.ajax({
    type: "POST",
    url: "https://mandrillapp.com/api/1.0/messages/send.json",
    data: {
      'key': 'my_api_key',
      'message': {
        'from_email': 'test@hotmail.com',
        'to': [{
          'email': 'test@gmail.com',
          'name': 'RECIPIENT NAME (OPTIONAL)',
          'type': 'to'
        }],
        'autotext': 'true',
        'subject': 'test',
        'html': 'test'
      }
    }
  }).done(function(response) {
    console.log(response);
  });
});
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

javascript email jquery mandrill

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

如何将 React Router 位置道具传递给组件?

我想弄清楚如何将 React Router 的 location 属性传递给组件。

我有一个这样定义的路线:

<Route
  path="placeholder"
  render={(props) => <Navigation {...props} />}
/>
Run Code Online (Sandbox Code Playgroud)

在我的 Navigation 组件中,我console.log(this.props);在 render 方法中所做的只是为了获取一个空对象。是什么赋予了?不应该将 location 道具自动提供给 Route 内的任何组件吗?

顺便说一句,我使用的是 react-router-dom version 4.2.2

javascript routing routes reactjs react-router

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

如何使用 JavaScript 检查元素在视口中是否可见一半?

我正在使用以下函数来检查元素在视口中是否可见:

function elementInViewport(el) {
  let top = el.offsetTop;
  let left = el.offsetLeft;
  const width = el.offsetWidth;
  const height = el.offsetHeight;

  while (el.offsetParent) {
    el = el.offsetParent;
    top += el.offsetTop;
    left += el.offsetLeft;
  }

  return (
    top < (window.pageYOffset + window.innerHeight)
    && left < (window.pageXOffset + window.innerWidth)
    && (top + height) > window.pageYOffset
    && (left + width) > window.pageXOffset
  );
}
Run Code Online (Sandbox Code Playgroud)

但是,我想检查一个元素是否50%在视口中可见。因此,如果仅显示一半,则支票应返回true。我知道使用 Intersection Observer API 可以做到这一点,但这对我来说不是一个选项,因为我希望它与IE11.

html javascript

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

如何通过CodeIgniter成功发送联系表单中的电子邮件?

我已经设置了我的控制器和我的联系表单.但是当我点击我的联系页面上的"提交"时,我没有收到任何错误,但是我没有收到任何电子邮件.任何人都可以帮我弄清楚为什么我实际上没有收到电子邮件?我感谢任何帮助.这是我的控制器代码:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
    public function index()
    {
        $this->template->build('home');
    }

    public function email() {
        $name = $this->input->post('name');
        $email = $this->input->post('email');
        $phone_number = $this->input->post('phone_number');
        $message = $this->input->post('message');
        $this->load->library('email');
        $this->email->from($email, 'Your Name');
        $this->email->to('anish@develop.io');
        $this->email->cc('another@another-example.com');
        $this->email->bcc('them@their-example.com');
        $this->email->subject('Email Test');
        $this->email->message(
          'My name is'.$name.', Im testing this email class. My email is '.$email. '. My Phone number is '.$phone_number.
         ' This is my message '.$message. ' Thanks!!'
         );
        $this->email->send();
        echo $this->email->print_debugger();
        $this->template->build('home');
    } …
Run Code Online (Sandbox Code Playgroud)

php email codeigniter contact-form

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

如何使用 Node.js 检查 MongoDB 中是否存在集合?

基本上,我想根据集合是否存在来隐藏div。有谁知道最简单的方法吗?我在 Jade 中使用 Mongoose 和 Express.js。

mongoose mongodb node.js express pug

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

如何将 id 属性应用于 ReactJS 组件的子元素?

所以我有一个下拉组件:

import React from 'react';
import { PropTypes } from 'prop-types';

export default class Dropdown extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      value: this.props.selectedDropdownValue,
    };

    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(e) {
    this.setState({
      value: e.target.value,
    });

    this.props.onChange(e.target.value);
  }

  render() {
    let disabled = false;
    let dropdownOptions = null;
    const { options } = this.props;

    // Disable dropdown is the disabled attribute is added
    if (options) {
      dropdownOptions = this.props.options.map((option) =>
        <option value={option.key} key={option.key} >{option.display}</option>,
      );
    } else {
      // …
Run Code Online (Sandbox Code Playgroud)

javascript html-select reactjs

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