代码之家  ›  专栏  ›  技术社区  ›  Djave

未在IE11中呈现Vuejs组件

  •  2
  • Djave  · 技术社区  · 8 年前

    我有一个类似这样的小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

    我是不是在用这个组件不支持的东西?

    1 回复  |  直到 8 年前
        1
  •  3
  •   Max Sinev    8 年前

    我在Vue对象中看到错误:

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

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