首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BootstrapVue -未定义属性或方法"data“...当使用作用域插槽时

BootstrapVue -未定义属性或方法"data“...当使用作用域插槽时
EN

Stack Overflow用户
提问于 2019-11-09 21:42:31
回答 1查看 235关注 0票数 1

你好,我正在学习使用BootstrapVue,我从BootstrapVue的官方文档中复制了一个例子-

代码语言:javascript
复制
<template>
  <div>
    <b-table :fields="fields" :items="items" foot-clone>
      <!-- A custom formatted data column cell -->
      <template v-slot:cell(name)="data">
        {{ data.value.first }} {{ data.value.last }}
      </template>

      <!-- A custom formatted header cell for field 'name' -->
      <template v-slot:head(name)="data">
        <span class="text-info">{{ data.label.toUpperCase() }}</span>
      </template>

      <!-- A custom formatted footer cell for field 'name' -->
      <template v-slot:foot(name)="data">
        <span class="text-danger">{{ data.label }}</span>
      </template>

      <!-- Default fall-back custom formatted footer cell -->
      <template v-slot:foot()="data">
        <i>{{ data.label }}</i>
      </template>
    </b-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        fields: [
          // A column that needs custom formatting
          { key: 'name', label: 'Full Name' },
          // A regular column
          'age',
          // A regular column
          'sex'
        ],
        items: [
          { name: { first: 'John', last: 'Doe' }, sex: 'Male', age: 42 },
          { name: { first: 'Jane', last: 'Doe' }, sex: 'Female', age: 36 },
          { name: { first: 'Rubin', last: 'Kincade' }, sex: 'Male', age: 73 },
          { name: { first: 'Shirley', last: 'Partridge' }, sex: 'Female', age: 62 }
        ]
      }
    }
  }
</script>

在教程页面上,似乎一切正常,但当我运行这个程序时,我总是得到这样的信息:Property or method "data" is not defined...我相信这是因为<template v-slot:cell(name)="data">部件不知何故没有实例化数据,但我不知道为什么和如何修复它,请帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-10 04:50:46

是的,版本是问题所在。我使用的是Vue 2.5.x,在我将它更新到2.6.10之后,它就像在教程中一样没有任何问题。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58779856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档