本文介绍了尝试向独立的SVG文件添加工具提示功能时,我收到“无效的'in'操作数样式"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将工具提示添加到独立的SVG文件中,但它返回以下错误:

I am trying to add tooltips to a standalone SVG file but it is returning the following error:

TypeError: invalid 'in' operand style
[Break On This Error]

if ( name in style ) {

对于以下jquery-2.0.0函数:

for the following jquery-2.0.0 function:

// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) {

    // shortcut for names that are not vendor prefixed
    if ( name in style ) {
        return name;
    }

    // check for vendor prefixed names
    var capName = name.charAt(0).toUpperCase() + name.slice(1),
        origName = name,
        i = cssPrefixes.length;

    while ( i-- ) {
        name = cssPrefixes[ i ] + capName;
        if ( name in style ) {
            return name;
        }
    }

    return origName;
}

如果我通过HTML页面显示svg文件,则可以正常工作.但是我需要将其用作纯SVG,并且无法做到这一点.

If I present the svg file through HTML page, it works fine. But I need it to work as a pure SVG and can’t manage to do that.

以下是在 HTML (有效)和 SVG (不是).工具提示插件称为工具提示工具(由Caleb Jacob开发).

Here is the same page expressed in HTML (works) and SVG (does not). The tooltip plugin is called tooltipster (developed by Caleb Jacob).

看来问题被错误地陈述了.这是keith-wood.name的相关报价:

edit: It seems that the question was stated incorrectly. Here’s a relevant quote from keith-wood.name:

可以在Internet上找到对原始jQuery版本的几处修改,以尝试解决此问题,但它们又不适用于最新版本的jQuery插件.

Several modifications of original jQuery versions can be found on the internet that try to solve this problem, but they in turn do not work with the most recent versions of jQuery plugins.

我不确定这是否能回答问题.

I am not sure if this makes the question answered or not though.

推荐答案

当我将jQuery降级到1.9.1版时,我遇到了IE10的问题,并且刚刚解决. http://code.jquery.com/jquery-1.9.1.min.js

I had this problem with IE10, and just solved, when I downgrade jQuery to version 1.9.1.http://code.jquery.com/jquery-1.9.1.min.js

这篇关于尝试向独立的SVG文件添加工具提示功能时,我收到“无效的'in'操作数样式"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 00:12
查看更多