方法未捕获SecurityError:阻止了具有原点的帧

Method Uncaught SecurityError: Blocked a frame with origin

本文关键字:原点 SecurityError 方法      更新时间:2024-02-15

该方法似乎有问题。当安装了"不安全"时,方法中的代码运行良好。谢谢

Uncaught SecurityError: Blocked a frame with origin "http://localhost:3000" from accessing a frame with origin "chrome-extension://oknpjjbmpnndlpmnhmekjpocelpnlfdi". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "chrome-extension". Protocols must match.

模板事件

Template.docEdit.events({
    'click .remove': function(event, template) {
        var thisTag = String(this);
        Meteor.call('removeTag', template, thisTag);
    },
});

方法

Meteor.methods({
    removeTag: function(template, thisTag) {
        MyPix.update (
            template.data._id,
            { $pull: { 'metadata.tags': thisTag }}
        );
    }
})

添加了"不安全"的后,这确实起到了作用

Template.docEdit.events({
    'click .remove': function(event, template) {
        var thisTag = String(this);
        MyPix.update (
            template.data._id,
            { $pull: { 'metadata.tags': thisTag }}
        );
    }
});

好的,我正在传递整个模板。该方法只需要id。

模板事件

Template.docEdit.events({
    'click .remove': function(event, template) {
        var thisTag = String(this);
        var thisId = template.data._id; // assign id to var
        Meteor.call('removeTag', thisId, thisTag);
    },
});

方法

Meteor.methods({
    removeTag: function(thisId, thisTag) {
        MyPix.update (
            thisId,
            { $pull: { 'metadata.tags': thisTag }}
        );
    },
})