【发布时间】:2015-08-06 09:56:11
【问题描述】:
我有一些 web 应用程序模块(我将其视为对象类),我想在 react-native 中重用它们。
但是 define 不起作用。我试过 amdefine 但没有成功。 我得到的错误是“定义未定义”。有什么想法吗?
一个例子:
调用者(index.ios.js):
var React = require('react-native');
var ExampleClass = require('./app/ExampleClass');
....
定义:
define('ExampleClass', [
// imports
'ParentClass',
'ExampleImport',
'ExampleImport2',
], function(ParentClass, ExampleImport, ExampleImport2) {
/**
* @class ExampleClass
*/
var ExampleClass = ParentClass.extend('ExampleClass');
ExampleClass.prototype.init = function() {
ParentClass.prototype.init.call(this);
var oExampleImport = new ExampleImport();
oExampleImport.doStuff();
};
ExampleClass.prototype.doSomething = function(oData, oStatus) {
.....
var oExampleImport2 = new ExampleImport2();
oExampleImport2.doMoreStuff();
};
return ExampleClass;
});
【问题讨论】:
-
你能展示一下尝试使用它的代码吗?还有错误。
-
根据您的需要更新了问题。 :)
标签: javascript react-native amdefine