简体   繁体   English

未在实例上定义属性或方法(…),但在渲染期间引用了该属性或方法

[英]Property or method (…) is not defined on the instance but referenced during render

"Property or method "show" 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" “属性或方法“ show”未在实例上定义,但在渲染过程中被引用。通过初始化属性,确保该属性在data选项中或对于基于类的组件都是反应性的”

This is my code. 这是我的代码。

 <script> import { SlideYUpTransition } from 'vue2-transitions' export default { data: () => ({ listitems: [{ title: '출결관리', path: '/attendanceCheck' }, { title: '학생관리', path: '/studentAdministration' }, { title: '알림설정', path: '/notificationSetting' } ], components: { SlideYUpTransition }, data() { return { show: true } } }) } </script> 
 <style> /*-- Contents --*/ /* .content { width: 580px; padding: 20px; margin-bottom: 20px; float: left; } */ @media ( max-width: 480px) { .container { width: auto; } .content { float: none; width: auto; } } </style> 
 <template> <!-- Contents ( Image, Notice ) --> <div class = "contents"> <section> <v-parallax src="/images/bg.png" height="650"></v-parallax> </section> <slide-y-up-transition > <div v-show="show">Your content here</div> </slide-y-up-transition> </div> </template> 

The structure of your component should have data and components as top-level properties: 组件的结构应具有datacomponents作为顶级属性:

export default {
  data: () => ({
    listitems: [
      {
        title: '출결관리',
        path: '/attendanceCheck'
      },
      {
        title: '학생관리',
        path: '/studentAdministration'
      },
      {
        title: '알림설정',
        path: '/notificationSetting'
      }
    ],
    show: true
  }),
  components: {
    SlideYUpTransition
  }
}

data is a function that returns the state of the component, and components is an object. data是一个返回组件状态的函数,而components是一个对象。

The primary reason for this error is that you might have used a " model " inside the " template " tag, but forgot to declare in the "data" section inside the " script " tag. 发生此错误的主要原因是您可能在“ template ”标签内使用了“ model ”,但忘记了在“ script ”标签内的“数据”部分中声明。

For Ex: 例如:

<template>
    <el-form ref="form" :model="form" label-width="120px"> ##<=== form model used here
        <el-form-item label="Name">
            <el-input v-model="form.name"></el-input>
        </el-form-item>
  </el-form>
 </template>

But inside your " Script " tag you might have not used it 但是在“ Script ”标签中,您可能没有使用过它

export default {

  data: () => ({

      form:{
          name: ''   <----- Declare andd initialize here
          }

  }),


  methods:{

  },

  components: {

  }
};

This will solve your problem.... 这将解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 属性或方法“_”未在实例上定义,但在渲染期间引用 - Property or method "_" is not defined on the instance but referenced during render [Vue警告]:属性或方法未在实例上定义,但在渲染期间被引用 - [Vue warn]:Property or method is not defined on the instance but referenced during render 属性或方法“greet”未在实例上定义,但在渲染期间被引用 - Property or method “greet” is not defined on the instance but referenced during render VueJS:属性或方法......未在实例上定义,但在渲染期间被引用 - VueJS: Property or method ... is not defined on the instance but referenced during render 属性或方法“名称”未在实例上定义,但在渲染期间被引用 - Property or method "names" is not defined on the instance but referenced during render Vue:属性或方法“APP”未在实例上定义,但在渲染期间引用 - Vue: Property or method “APP” is not defined on the instance but referenced during render 未在实例上定义但在渲染期间引用的属性或方法 I Vuex - Property or method not defined on the instance but referenced during render I Vuex [Vue 警告]:属性或方法“hp”未在实例上定义,但在渲染期间引用 - [Vue warn]: Property or method "hp" is not defined on the instance but referenced during render Vue属性或方法未在实例上定义但在渲染期间引用? - Vue property or method is not defined on the instance but referenced during render? 错误:属性或方法“用户”未在实例上定义,但在渲染期间引用 - Error: Property or method “users” is not defined on the instance but referenced during render
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM