vue报错:Property or method "active" is not defined on the instance

vue.runtime.esm.js?0261:619 [Vue warn]: Property or method “active” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

这个报错是因为你在template里面或者在方法里面使用了 “active” ,但是在data里面没有定义。

<van-tabs v-model="active">
  <van-tab title="标签 1">内容 1</van-tab>
  <van-tab title="标签 2">内容 2</van-tab>
  <van-tab title="标签 3">内容 3</van-tab>
  <van-tab title="标签 4">内容 4</van-tab>
</van-tabs>
export default {
  data() {
    return {
      active: 2
    };
  }
}

找到了是v-model绑定的active忘记在data里定义了

你可能感兴趣的:(前端)