internet-explorer - VueJS 组件无法在 IE11 中呈现

标签 internet-explorer vue.js internet-explorer-11

我有一个像这样的小 Vue 应用程序:

<div id="app">
  <div class="row">
    <div>
      <statistic
        class-name="stat-1"
        :amount="amount"
        :postfix="postfix"
        :prefix="prefix"
        :scale="scale"
        :accuracy="accuracy"></statistic>
    </div>
    <div><!-- controls --></div>
  </div>
</div>

JS:

Vue.component('statistic', {
  props: ['amount', 'postfix','scale', 'className', 'accuracy', 'prefix','fill'],

  /* config here */

  template:`<div class="animated-statistic" :class="className">
    <svg class="animated-statistic--graphic"  width="200" height="200" viewBox="0 0 200 200">
      <defs>
        <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
          <stop offset="0%" style="stop-color:rgb(249,232,154);stop-opacity:1" />
          <stop offset="100%" style="stop-color:rgb(229,107,233);stop-opacity:1" />
        </linearGradient>
      </defs>
      <circle cx="100" cy="100" :r="radius" fill="url(#grad1)"></circle>
    </svg>
    <div class="animated-statistic--text" v-text="value"></div>
  </div>`
});

这很好用 – link to working Codepen

但是,如果您在 IE11 中点击相同的链接,则该组件所在的位置会出现一个空白区域。除非我没有正确使用 IE,否则我在控制台中看不到任何错误。

最初我认为可能是 IE 中的 SVG 有问题,但我做了 another copy of the pen使用静态 SVG 并且它正在渲染。

如果您在 IE11 中检查元素,您只会看到 <statistic></statistic>标记 - 它们不会被渲染。

enter image description here

我使用的是 IE 不支持的东西吗?

最佳答案

我在此处的 Vue 对象中看到错误:

Vue.component('statistic-animation', {
  props: ['amount', 'postfix','scale', 'className', 'accuracy', 'prefix','fill'],
  data(){   // ERROR!
    return {
       current : this.amount,
    }
  },
 ....

IE 11 不支持对象中的短方法定义语法 - source

关于internet-explorer - VueJS 组件无法在 IE11 中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50682725/

相关文章:

javascript - IE11/Edge 不遵守 DOM 中的链接/CSS 顺序

具有混合值类型的 JavaScript 数组排序 - 寻找合适的比较函数

javascript - 无法在 IE 中附加 "used"DOM 对象

javascript - VueJs 超出最大调用堆栈大小

javascript - 如何在 vue cli 中使用 Moment.js

vue.js - Nuxt基于域名的动态布局?

css - SVG 动画不适用于 IE11

javascript - 从二进制字符串或 base64 在 Internet Explorer 11 中显示嵌入式 PDF

html - IE7 显示问题(添加额外的上边距)

c# - 通过 WPAD 中定义的代理与 Web 服务通信