我正在调试一个可视化作曲家插件,在我将Wordpress更新到4.5之后就破坏了,我无法弄清楚它为什么会抛出TypeError.
控制台中的错误消息:
JQMIGRATE: Migrate is installed, version 1.4.0 load-scripts.php?....
Uncaught TypeError: $template.get is not a function composer-view.js?ver=4.1.1.1:73
Run Code Online (Sandbox Code Playgroud)
唯一出现的$template情况可以在下面的代码中找到.我明白这不是很多背景,但是,我该如何解决这个错误呢?
/**
* Convert html into correct element
* @param html
*/
html2element: function(html) {
var attributes = {},
$template;
if (_.isString(html)) {
this.template = _.template(html);
$template = $(this.template(this.model.toJSON()).trim());
} else {
this.template = html;
$template = html;
}
_.each($template.get(0).attributes, function(attr) { // **errors on this line**
attributes[attr.name] = attr.value;
});
this.$el.attr(attributes).html($template.html());
this.setContent();
this.renderContent();
},
Run Code Online (Sandbox Code Playgroud)
更新:
看起来这可能是jQuery的一个问题.Wordpress 4.5包含jQuery 1.12,修复了一个允许某些代码以不正确的语法运行的错误.我假设插件代码必须具有不正确的语法,但直到现在仍然运行.
https://wordpress.org/support/topic/read-this-first-wordpress-45-master-list#post-8271654
当我使用名为WpBakery Visual Composer的插件时,我在WordPress中收到此错误.
我正在使用最新版本的WordPress(4.5),使用最新的谷歌Chrome版本,所有插件都会更新.我似乎无法使用Visual Composer添加任何元素或模板.
有人可以帮助我或告诉我可能会发生什么以及如何解决此错误.
我得到的错误:
我的视觉作曲家插件不起作用.它停留在加载页面上.并且它给出了一个错误"TypeError:.template(...).trim不是函数"错误出现在这行代码中:this.$ controls = $(.template(template,data,vc.template_options).trim ())addClass( 'vc_controls');
请帮我解决这个问题.
这是我得到的错误: