我最近将 Webpack 集成到我的项目中,为我网站上的 JS 文件构建捆绑包。修复了一些小问题后,我能够构建捆绑包。在浏览器中检查后,其中一个 Javascript 代码引发了以下错误。
经过检查,我意识到 addComment.moveform 导致了问题。
因此,我检查了生成的包,发现变量 addComment 的定义尚未推送到包中。如下编写的 Javascript 是否有原因不会被捆绑?Webpack 没有抛出错误吗?
/**
* 'Comment Reply' to each comment.
* This script moves the Add Comment section to the position below the appropriate comment.
* Modified from Wordpress https://core.svn.wordpress.org/trunk/wp-includes/js/comment-reply.js
* Released under the GNU General Public License - https://wordpress.org/about/gpl/
*/
var addComment = {
moveForm: function(commId, parentId, respondId, postId) {
var div,
element,
style,
cssHidden,
t = this,
comm = t.I(commId),
respond = t.I(respondId),
cancel = …
Run Code Online (Sandbox Code Playgroud) 我试图将字符串列表初始化为private static final,但我总是得到l
as的值,如果我如第二段代码所示将其声明为有效。
我想做的是将我声明的列表的元素添加到特里以稍后匹配某些模式...
关于为什么第一个示例中的null值有什么想法,我该如何纠正?谢谢
public class Myclass {
public static final Myclass INSTANCE = new Myclass();
private static final List<String> l = Arrays.asList("ofo", "oof", "foo");
private Trie trie;
private Myclass() {
trie = buildTrie();
}
private Trie buildTrie() {
TrieBuilder builder = Trie.builder();
Iterator<String> iterator = l.iterator();
while (iterator.hasNext()) {
builder.addKeyword(iterator.next());
}
return builder.build();
}
}
Run Code Online (Sandbox Code Playgroud)
public class Myclass {
public static final Myclass INSTANCE = new Myclass();
private Trie trie;
private Myclass() {
List<String> l = …
Run Code Online (Sandbox Code Playgroud)