tmodjs icon indicating copy to clipboard operation
tmodjs copied to clipboard

使用require合并后不执行

Open goWrongWay opened this issue 11 years ago • 6 comments

qq 20141112022037 目录结构

1 index.html

2 index.js

3 header.html

可以正常生成cmd模块,显示也正常。但是使用r.js合并的时候无报错,无页面。文件都已经合并到built里面了,好像依赖有问题一样。求解。

goWrongWay avatar Nov 11 '14 18:11 goWrongWay

很可能是合并后的js没有添加模块id的问题,你检查下?

aui avatar Nov 12 '14 01:11 aui

我给您发邮件了...您帮帮我吧。gmail的。

goWrongWay avatar Nov 12 '14 03:11 goWrongWay

就在 github 上解决吧(邮件可能被拦截了)。

试试设置 tmodjs 的 "type": "amd" 试试,这是 requirejs 遵循的规范

aui avatar Nov 12 '14 03:11 aui

这个当然设置了 qq 20141112113023 这是截图,现在好像是ID 依赖错误 但是我手动更改了以后,不报错。还是没结果啊

goWrongWay avatar Nov 12 '14 03:11 goWrongWay

入口文件使用define(。。。。。。。)定义的,依赖了两个文件。 不适用define。 直接require。 解决了。还是感谢作者的帮助。

goWrongWay avatar Nov 12 '14 05:11 goWrongWay

请问是怎么解决的。我压缩后的文件member.js

/*TMODJS:{"version":14,"md5":"cf25235ea89d80fcbaa1ad9183dd3dca"}*/
define("dist/tpl/memberList", [ "./template" ], function(require) {
    return require("./template")("memberList", function(a) {
        "use strict";
        var b = this, c = (b.$helpers, b.$each), d = a.list, e = (a.item, a.$index, b.$escape), f = "";
        return f += " ", c(d.Items, function(a) {
            f += ' <li data-id="', f += e(a.AddrId), f += '" data-url="/home/_memberview?addrid=', 
            f += e(a.AddrId), f += '"> <div class="avatar"><img alt="', f += e(a.UserName), 
            f += '" class="face" src="', f += e(a.Avatar), f += '" /></div> <div class="detail"> <p class="no-wrap">', 
            f += e(a.UserName), f += "(", f += e(a.UserId), f += ')</p> <p class="addr">', f += e(a.Area), 
            f += e(a.Street), f += '</p> <p class="no-wrap">', f += e(a.Mobile), f += '</p> </div> <div class="selector"><input type="radio" name="name" /></div> <div class="action"><a class="edit no-wrap">编辑</a><a class="del no-wrap">删除</a><a class="default no-wrap">默认</a></div> </li> ';
        }), f += " ", new String(f);
    });
});

/*TMODJS:{"version":8,"md5":"aa743d8a6a0cbc062ec191ca4568e18a"}*/
define("dist/tpl/memberView", [ "./template" ], function(require) {
    return require("./template")("memberView", function(a) {
        "use strict";
        var b = this, c = (b.$helpers, b.$escape), d = a.user, e = "";
        return e += ' <div><img alt="', e += c(d.UserName), e += '" class="face" src="', 
        e += c(d.Avatar), e += '" /></div> <p>电话:', e += c(d.Mobile), e += "</p> <p>用户名:", 
        e += c(d.UserName), e += "(", e += c(d.UserId), e += ")</p> <p>地址:", e += c(d.Street), 
        e += '</p> <a id="hide" class="btn btn-default" href="javascript:;">hide me »</a> ', 
        new String(e);
    });
});

提示 TypeError: require(...) is not a function; 到底是怎么压缩的?

jaryway avatar Jan 21 '15 16:01 jaryway