【问题标题】:object doesn't support property or method 'fillText' in IE8对象不支持 IE8 中的属性或方法“fillText”
【发布时间】:2023-04-11 06:31:01
【问题描述】:

我在 IE8 中遇到以下问题。我的代码在 Chrome、Mozilla 和 IE10 中运行良好。由于 IE8 不支持画布,我在其中遇到以下问题:

对象不支持属性或方法'fillText'

这是我收到此错误的 jQuery 行:

context.font = basefont+"px 'Trebuchet MS', Verdana, sans-serif";
context.fillText( (Math.round(parseFloat(v['value'] / totalValue * 1000 ))) /

有人有解决办法吗?

【问题讨论】:

  • 使用 polyfill。谷歌“canvas polyfill”

标签: javascript jquery internet-explorer-8 html5-canvas polyfills


【解决方案1】:

您可以尝试使用Webshims,它为旧版本的 Internet Explorer 启用 HTML5 和 CSS3 功能,如语义标签、画布、网络存储、地理定位、表单和多媒体。

由于它基于jQuery 和Modernizr,因此您需要在Webshims Lib 旁边包含依赖项jQuery 和Modernizr:

<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.1/modernizr.min.js"></script>
<script src="scripts/webshim/polyfiller.js"></script>

之后,为了初始化 Webshims 并要求支持 canvas 元素,你可以这样做:

$.webshims.polyfill('forms canvas'); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多