我正在编写两个组件 - ComponentA并且ComponentB,在ComponentA封装时ComponentB.他们俩都有一个p标签.在我ComponentA,我正在写风格:p { color:red }我的@Component装饰师.该ComponentA的p更改为红色,但ComponentB的颜色保持黑色.
我认为这是一个需要解决的问题.
我是meteor和mongo db的新手.我正在使用meteor@1.3.4.1申请.我正在创建一个名为'/imports/api/collections/recipe.js'的文件.在这里,我创建一个集合并将此文件导入'/server/main.js'和'/client/main.js'.在recipe.js中,我只发布Recipe集合,然后在我的客户端文件中我订阅它.直到这一点,一切都是正确的.然后我使用autoform创建一个表单,它运行良好并创建.但这种形式永远不会发布.
首先,我的假设是当服务器启动时,那时我的数据库应该创建一个名为recipe的集合,但事实并非如此.
其次,为什么autoform不起作用?我认为这是因为第一个原因.
在客户端,我通过蒙古(流星玩具)看到我的食谱收藏.
我的食谱文件 - '/imports/api/collections/recipe.js':
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
var RecipesCollection = new Mongo.Collection('recipes');
RecipesCollection.allow({
insert(userId, doc){
return !!userId;
}
})
var RecipeSchema = new SimpleSchema({
name: {
type: String,
label: "Name"
},
desc: {
type: String,
label: "Description"
},
author: {
type: String,
label: "Author",
autoValue(){
return this.userId
},
autoform:{
type: "hidden"
}
},
createdAt: {
type: Date,
label: "Created At",
autoValue(){ …Run Code Online (Sandbox Code Playgroud) mongodb meteor meteor-blaze meteor-autoform meteor-collection2
我无法找到 Babel 编译器无法编译的一组已定义功能。我知道有 babel-polyfill 和 core.js 但我需要知道 babel 编译器无法编译的 es2015 功能的确切名称。
任何帮助,将不胜感激。
谢谢
请看下面的代码:
情况1:
var a = {
b: function(){
console.log(a)
},
c:1
};
Run Code Online (Sandbox Code Playgroud)
案例2:
var a = {
b:a,
c:1
};
Run Code Online (Sandbox Code Playgroud)
现在当我写这个:
a.b() // for first
console.log(a.b) // for 2nd
Run Code Online (Sandbox Code Playgroud)
我得到结果:
{c:1}
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
它的父母'a'的属性'b'如何通过其名称访问其父'a',即'a'?
如果它正在访问它,那么为什么它不显示'a'的所有属性?
据我所知,JavaScript中的对象是通过引用而不是值复制的.但是我写的下面的代码没有按预期工作.也许我不知道正确的行为.请提供见解和可能的解决方案,以避免这种情况.
我的代码:
var a = {
obj:{u:1,v:2,w:3},
setobj:function(objj){
this.obj = objj
}
};
var b = a;
var m = b.obj
console.log(m);
Run Code Online (Sandbox Code Playgroud)
它打印 - {u:1,v:2,w:3},
然后-
var c = a;
c.setobj({x:4,y:5});
console.log(c.obj); //prints {x:4,y:5}
console.log(a.obj); //prints {x:4,y:5}
console.log(b.obj); //prints {x:4,y:5}
Run Code Online (Sandbox Code Playgroud)
但:
console.log(m); //prints {u:1,v:2,w:3}
Run Code Online (Sandbox Code Playgroud)
我期待m包含b.obj的引用,其中b包含a的引用.后者正在工作,但前者(m的参考)不起作用.请提供一个洞察力,告诉我我错过了什么.这是我的非常愚蠢的假设还是有些我不知道的事情?
我正在创建一个库,从中导出 React 组件以及一些接口和枚举。我编译了打字稿项目。这是因为该库是针对 React 而不是 Typescript 的。我也在创建正确的定义文件。
现在在我的消费者项目中,我正在这样做:
import { IMyComponentProps, MyComponent } from "mycomp-lib";
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我能够使用IMyComponentProps. 我将其用于一个函数,该函数将进行一些计算并返回 的 props MyComponent。
但从我的库中,我还导出一个枚举,如下所示:
export const enum DirectionEnum {
UP,
DOWN,
RIGHT,
LEFT
}
Run Code Online (Sandbox Code Playgroud)
但当我这样做时import { IMyComponentProps, MyComponent, DirectionEnum } from "mycomp-lib";
DirectionEnum我开始收到未从 导出的错误mycomp-lib。
这个枚举是必需的,因为即使 的使用者mycomp-lib是用纯 JavaScript 编写的,它也很有用。但在 typescript 项目中,它肯定是需要的。
我正在使用 typescript v3 和 React v16.3。
javascript ×4
angular ×1
babeljs ×1
enums ×1
meteor ×1
meteor-blaze ×1
mongodb ×1
reactjs ×1
typescript ×1