es6-class

    0热度

    1回答

    我有一个已定义这样的,有一对夫妇的功能的ES6类: class Cell{ constructor(i,j){ this.i = i; this.j = j; this.alive = false; this.survives = false; //Made so not to change alive variabe mid-loop,

    1热度

    1回答

    用Mongoose探索Javascript ES6类,并且无法访问类变量。我想在cursor.on(data)事件中使用this.name引用在类的构造函数中声明的变量。我怎样才能做到这一点? 'use strict'; const Mongo = require('../mongo') class Example { constructor() { this.name

    0热度

    1回答

    使用JavaScript ES6我有几个类,我想要分离我的应用程序的各种问题。我有一个main.js文件,我希望实例化这些类,然后能够引用和调用它们之间的方法。 我的问题是:什么是最好的/标准的方式来做到这一点?我目前的做法如下: 在main.js我创造出实例两类 import ClassOne from './ClassOne'; import ClassTwo from './ClassTw

    0热度

    1回答

    对于es6我很新。以下是我的简单Student类与接受2个参数的构造函数。我通过在构造函数签名本身中调用函数来分配默认值,当参数未被传递时。 index.js:9Uncaught TypeError: this.defaultRno is not a function at new Student (index.js:9) at Object.<anonymous> (inde

    0热度

    1回答

    尽管我并不是很强调将OOP强制为函数式语言,但我正在努力了解我的同行做了什么以导出类中的模块。我所寻找的是所谓的这个,所以我可以继续研究。从我所了解的他们包括一些外部SDK被传递到一个内部类将继承一切到LibIncludes。这是假设允许所有的类继承到从Object继承的LibIncludes和LibIncludes中。我现在遇到的情况是,只要我尝试调用LibIncludes.Handlers;并

    1热度

    1回答

    我想让我的网站适合所有知名的浏览器 在所有浏览器中,我的JavaScript代码正在工作,但在Safari中无法使用。 我得到一个错误的Safari:“语法错误:使用保留字‘类’的” 我的代码是这样的: class _MontInit { constructor() {} sendXMLHTTPRequest(url, data, method, callback, error

    0热度

    1回答

    我想弄清楚这里发生了什么,因为父类/超类在初始构建后没有数据。 //进口/服务器/一 - 和 - b.js class A { constructor(id) { // make MongoDB call and store inside this variable // ... this._LocalVariable = FieldFromMongo;

    1热度

    2回答

    我想使用ES6解构一个类的构造函数,但得到一个未知的令牌错误。这里有一个例子: //进口/服务器/ A-和b.js class A { constructor(id) { // make MongoDB call and store inside this variable let { firstName: this._FirstName // => Th

    1热度

    1回答

    我想创建一个BankAccount类,其中新实例跟踪新实例的检查和节省。然而,每当有人创建一个新实例时,我想要一个静态方法,它调用一个静态字段,该字段仅与BankAccount类相关,该类可以跟踪有多少银行帐户已打开(有点像单例行为)。这在c#/ java中是可行的,但很难在Javascript中重新创建预期的行为。 我在ES5尝试这很好,但短了,我来我一直在寻找使用功能的包装来封装行为最接近的事

    -1热度

    2回答

    我做这个类: import React, {Component} from 'react'; import { View, ActivityIndicator, Button } from 'react-native'; import Auth from '../api/Auth'; export default class LoginScreen ex