// 最外层多个标签,无法在使用子组件标签上定义 class
  // 会报错:[Vue warn]: Extraneous non-props attributes (class) 
  // were passed to component but could not be automatically inherited 
  // because component renders fragment or text root nodes. 
  // at <Demo3 class="green" > at <App>
  // 下面把这个问题解决了:绑定父标签的属性值
  app.component('demo3', {
    template: `
        <div :class="$attrs.class">zibo31</div>
        <div :class="$attrs.class">zibo32</div>
    `
  });

Logo

前往低代码交流专区

更多推荐