小编Mow*_*zer的帖子

如何将样式应用于元素的所有子元素

我有一个元素class='myTestClass'.如何将css样式应用于此元素的所有子元素?我只想将样式应用于元素子元素.不是它的大孩子.

我可以用

.myTestClass > div {
  margin: 0 20px;
}
Run Code Online (Sandbox Code Playgroud)

哪个适合所有div孩子,但我想找一个适合所有孩子的解决方案.我以为我可以用*,但是

.myTestClass > * {
  margin: 0 20px;
} 
Run Code Online (Sandbox Code Playgroud)

不起作用.

编辑

.myTestClass > *选择不使用Firefox 26应用规则,并有根据萤火没有其他规则的保证金.和它的作品,如果我取代*div.

css css-selectors

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

如何在Google文档中关闭分页符?

如何关闭Google文档中的分页符,以便我只有一个连续滚动文档?

我不认为这种方法适用.

我从不想打印出我的Google文档.分页符分散了注意力并弄乱了我的格式.(例如,当我有一个带有脚注的表格跨越页面边界时,脚注就会破坏表格!)

google-docs

77
推荐指数
9
解决办法
10万
查看次数

如何使用Firestore更新"对象数组"?

我正在尝试Firestore,而且我遇到了一些非常简单的事情:"更新一个数组(也就是一个子文档)".

我的DB结构非常简单.例如:

proprietary: "John Doe",
sharedWith:
  [
    {who: "first@test.com", when:timestamp},
    {who: "another@test.com", when:timestamp},
  ],
Run Code Online (Sandbox Code Playgroud)

我正在尝试(没有成功)将新记录推送到shareWith对象数组中.

我试过了:

// With SET
firebase.firestore()
.collection('proprietary')
.doc(docID)
.set(
  { sharedWith: [{ who: "third@test.com", when: new Date() }] },
  { merge: true }
)

// With UPDATE
firebase.firestore()
.collection('proprietary')
.doc(docID)
.update({ sharedWith: [{ who: "third@test.com", when: new Date() }] })
Run Code Online (Sandbox Code Playgroud)

没有用.这些查询会覆盖我的数组.

答案可能很简单,但我找不到......

谢谢

javascript arrays object firebase google-cloud-firestore

70
推荐指数
7
解决办法
6万
查看次数

在React中导入JSON文件

我是React的新手,我正在尝试DATA从外部文件导入JSON 变量.我收到以下错误:

找不到模块"./customData.json"

有人可以帮助我吗?如果我有DATA变量index.js但它不在外部JSON文件中时,它可以工作.

index.js
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import customData from './customData.json';
import Profile from './components/profile';
import Hobbies from './components/hobbies';

class App extends Component {
  render() {
    return (
      <div>
        <Profile name={this.props.profileData.name}imgUrl={this.props.profileData.imgURL} />
        <Hobbies hobbyList={this.props.profileData.hobbyList}/>
      </div>
    );
  }
}

ReactDOM.render(<App profileData={DATA}/>, document.querySelector('.container'));
Run Code Online (Sandbox Code Playgroud) hobbies.js
import React, {Component} from 'react';

var Hobbies = React.createClass({
  render: function(){
    var hobbies = this.props.hobbyList.map(function(hobby, index){
        return (<li key={index}>{hobby}</li>);
    });
    return (
        <div>
            <h5>My hobbies:</h5> …
Run Code Online (Sandbox Code Playgroud)

javascript json reactjs

53
推荐指数
11
解决办法
9万
查看次数

这是什么意思......在React JSX中休息

看看这个React Router Dom v4示例https://reacttraining.com/react-router/web/example/auth-workflow我看到PrivateRoute组件破坏了这样的休息道具

const PrivateRoute = ({ component: Component, ...rest }) => (
  <Route {...rest} render={props => (
    fakeAuth.isAuthenticated ? (
      <Component {...props}/>
    ) : (
      <Redirect to={{
        pathname: '/login',
        state: { from: props.location }
      }}/>
    )
  )}/>
)
Run Code Online (Sandbox Code Playgroud)

我想确定这{ component: Component, ...rest }意味着:

props,获取Component prop,然后获取给你的所有其他道具,并重命名props为,rest这样你就可以避免使用传递给Route render函数的props的命名问题

我对吗?

reactjs react-router

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

尝试初始化Cloud Firestore时,firebase.firestore()不是一个函数

当我尝试初始化Firebase Cloud Firestore时,遇到以下错误:

未捕获的TypeError:WEBPACK_IMPORTED_MODULE_0_firebase .firestore不是函数

npm install firebase --save以前安装了firebase .

import * as firebase from 'firebase';
import router from '../router';

const config = {
        apiKey: "a",
        authDomain: "a",
        databaseURL: "a",
        projectId: "a",
        storageBucket: "a",
        messagingSenderId: "a"
};
if(!firebase.apps.length){
  firebase.initializeApp(config);
  let firestore = firebase.firestore();
}
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-firestore

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

Polymer 1.0:如何从属性中将参数传递给Polymer函数?

有没有办法从其内部的元素属性传递参数到Polymer函数<template>

<script src="http://www.polymer-project.org/1.0/samples/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html" />
<dom-module id="example-element">
  <template>
    ...
    <paper-button id="foo" on-tap="bar">Click</paper-button>
    ...
  </template>
</dom-module>
<script>
  (function() {
    Polymer({
      is: 'example-element',
      properties: {...},
      bar: function(arg){
        // Do stuff using argument arg
      }
    });
  })();
</script>
Run Code Online (Sandbox Code Playgroud)

背景研究

我已经梳理关于此事的沉默文件.它没有说你是否可以.但是当我尝试它时,它失败了.但也许我没有正确地做到这一点.所以我需要一些帮助.

我唯一遇到的是事件监听器,它似乎无法接受我想传递的参数.说,一个id或一个name.

以前的尝试

我尝试过(不成功)做的事情:

<paper-button id="foo" on-tap="bar('foo')"> Click </paper-button>
Run Code Online (Sandbox Code Playgroud)

但似乎没什么用.

事件监听器的想法不起作用,因为它们限制了参数,我无法得到,比方说,id我需要.

polymer polymer-1.0

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

React-Redux:动作必须是普通对象.使用自定义中间件进行异步操作

未处理的拒绝(错误):操作必须是普通对象.使用自定义中间件进行异步操作.

详细信息:我想在每个帖子中添加评论.因此,当运行获取帖子时,我想为所有帖子调用fetch comment API.

这是我的代码:

export function bindComments(postId) {
  return API.fetchComments(postId).then(comments => {
    return {
      type: BIND_COMMENTS,
      comments,
      postId
    }
  })
}
Run Code Online (Sandbox Code Playgroud)

谢谢

reactjs react-redux

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

如何从命令行(CLI)更改Firebase用户登录标识?

我正在尝试使用User-Alice的登录凭据登录firebase.

但是当我通过授权程序时,我收到一条消息,说我以User-Bob身份登录.这在文档中没有提到,也没有解释如何更改我登录的用户.

如何将Firebase登录用户从User-Bob更改为User-Alice?

command-line command-line-interface firebase

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

如何在PC上本地测试Firebase的云功能

今天,Firebase发布了全新的Cloud Products for Firebase产品,我刚创建了一个hello world功能,并将其部署在我现有的firebase项目中.

看起来它捆绑所有依赖项并将其上传到firebase就像aws lambda函数一样.但即使在代码的微小变化上也需要太多时间才能完成,并且还需要良好的互联网连接.如果由于某种原因您处于脱机状态,那么在您可以在本地计算机上执行和测试该功能的方法之前,您所处的代码就处于黑暗状态.

有没有办法在本地测试Firebase的云功能?

function node.js firebase google-cloud-functions firebase-cloud-functions

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