gpt4 book ai didi

javascript - 未捕获的类型错误无法读取未定义的视觉 Composer 的属性 'attributes'

转载 作者:行者123 更新时间:2023-11-29 16:07:00 24 4
gpt4 key购买 nike

我有一些视觉 Composer 问题。由于旧版本无法获得支持。客户不会付款。问题是我无法在后端添加元素。Chrome 调试错误:

我已经尝试用代码解决这个问题:未捕获的类型错误:无法读取未定义的属性“属性”

<pre>
html2element @ composer-view.js?ver=4.7.4:156
render @ composer-view.js?ver=4.7.4:163
addShortcode @ composer-view.js?ver=4.7.4:232
addShortcode @ composer-view.js?ver=4.7.4:561
_ @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
m @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
f @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
l.trigger @ load-scripts.php?c=0&load[]=thickbox,hoverIntent,common,admin-bar,word-count,suggest,wp-ajax-respon…:474
ListenerHelper.triggerShortcodeEvents @ events.js?ver=4.7.4:19
(anonymous function) @ composer-view.js?ver=4.7.4:977
and alot fo load script errors
</pre>

代码:

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()
},

我已经检查了整个网络和 stackoverflow,我找不到这个问题的问题。

最佳答案

最好的解决方案是将 html2element 代码和 composer View 中的渲染代码替换为以下代码

html2element: function(html) {
var attributes = {},
$template;
if (_.isString(html)) {
this.template = _.template(html);
$template = $(this.template(this.model.toJSON(), vc.templateOptions.default).trim());
} else {
this.template = html;
$template = $(this.template(this.model.toJSON(), vc.templateOptions.default).trim());
}

_.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value;
});
this.$el.attr(attributes).html($template.html());
this.setContent();
this.renderContent();

},
render: function() {
var $shortcode_template_el = $('#vc_shortcode-template-' + this.model.get('shortcode'));
if ($shortcode_template_el.is('script')) {
this.html2element(_.template($shortcode_template_el.html()));
} else {
var params = this.model.get('params');
$.ajax({
type: 'POST',
url: window.ajaxurl,
data: {
action: 'wpb_get_element_backend_html',
data_element: this.model.get('shortcode'),
data_width: _.isUndefined(params.width) ? '1/1' : params.width,
_vcnonce: window.vcAdminNonce
},
dataType: 'html',
context: this
}).done(function(html) {
this.html2element(html);
});
}
this.model.view = this;
this.$controls_buttons = this.$el.find('.vc_controls > :first');
return this;
},

来源:https://gist.github.com/maximspokoiny/34ad60ad90944f8a80c6fc093873a807/9fb041d2b12249fe4391f986f4e7e6a08f57c6b3#file-gistfile1-txt

关于javascript - 未捕获的类型错误无法读取未定义的视觉 Composer 的属性 'attributes',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38873828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com