javascript – WordPress 4.5更新后插件抛出TypeError
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – WordPress 4.5更新后插件抛出TypeError,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1600字,纯文字阅读大概需要3分钟。
内容图文
![javascript – WordPress 4.5更新后插件抛出TypeError](/upload/InfoBanner/zyjiaocheng/708/b9f2c58908f24d3b99b94188f02ec586.jpg)
我正在调试一个视觉作曲家插件,在我将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
$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();
},
更新:
看起来这可能是jQuery的一个问题. WordPress 4.5包含jQuery 1.12,修复了一个错误,允许某些代码以不正确的语法运行.我假设插件代码必须具有不正确的语法,但直到现在仍然运行.
https://wordpress.org/support/topic/read-this-first-wordpress-45-master-list#post-8271654
解决方法:
我能够解决这个问题.事实证明我使用的是旧版本的JS作曲家.更新到最新版本会破坏我的网站,因此我追踪错误并将html2element函数更新为
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
}), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
},
一切都很适合我!希望这有助于其他人.
内容总结
以上是互联网集市为您收集整理的javascript – WordPress 4.5更新后插件抛出TypeError全部内容,希望文章能够帮你解决javascript – WordPress 4.5更新后插件抛出TypeError所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。