[英]Derby.js: split client-side only code into several files
I'm trying to split some client-side-only code into several files in a Derby.js project. 我试图在Derby.js项目中将一些仅客户端代码分成几个文件。 It has to be client-side only since it's interacting with the TinyMCE editor.
仅当它与TinyMCE编辑器进行交互时,它才必须是客户端。 So I tried:
所以我尝试了:
app.ready(function(model) {
var tiny = derby.use(require('../../lib/app/TinyMCE'))
//other client-side code
}
and put the following into lib/app/TinyMCE.js
: 并将以下内容放入
lib/app/TinyMCE.js
:
var derby = require('derby')
module.exports.decorate = 'derby'; //because before I got an 'decorate' is undefined error...
module.exports.TinyMCE = function() {
//code
}
But now I'm getting a object is not a function
error. 但是现在我得到的
object is not a function
错误。
Am I even on the right track? 我是否在正确的轨道上? I also considered putting the code in the public directory, but the cache-expiration of one year makes this rather inconvenient.
我也考虑过将代码放在公共目录中,但是一年的缓存过期使它相当不方便。
Also, is there really no isServer
or isClient
method to query? 另外,真的没有
isServer
或isClient
方法可查询吗?
Okay, I don't know whether that's a good way, but I got it working: 好的,我不知道这是否是一个好方法,但是我知道它可以工作:
module.exports = tiny
tiny.decorate = 'derby'
function tiny() {
//code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.