Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript [Vue warn]:属性或方法;onSave“;未在实例上定义,但在渲染期间引用_Javascript_Vue.js_Vue Component_Nuxt.js_Nuxtjs - Fatal编程技术网

Javascript [Vue warn]:属性或方法;onSave“;未在实例上定义,但在渲染期间引用

Javascript [Vue warn]:属性或方法;onSave“;未在实例上定义,但在渲染期间引用,javascript,vue.js,vue-component,nuxt.js,nuxtjs,Javascript,Vue.js,Vue Component,Nuxt.js,Nuxtjs,我不确定在我所做的更新过程中发生了什么,但我现在收到了一个以前没有收到的错误。我在index.vue下的pages文件夹中有一段代码: <section class="intro"> <h1>heading 1</h1> <h2>heading 2</h2> <nuxt-link to="/admin"> <AppButton type="

我不确定在我所做的更新过程中发生了什么,但我现在收到了一个以前没有收到的错误。我在index.vue下的pages文件夹中有一段代码:

<section class="intro">
  <h1>heading 1</h1>
  <h2>heading 2</h2>
  <nuxt-link to="/admin">
    <AppButton
      type="submit"
      @click="onSave">
      Start Here
    </AppButton>
  </nuxt-link>
  <nuxt-link to="/connect">
    <AppButton
      type="submit"
      @click="onSave">
      Contact Us
    </AppButton>
  </nuxt-link>
</section>

<script>
import AppButton from '@/components/UI/AppButton'

export default {
  components: {
    AppButton
  }
}
</script>

标题1
标题2
从这里开始
联系我们
从“@/components/UI/AppButton”导入AppButton
导出默认值{
组成部分:{
应用按钮
}
}
布局中default.vue文件下的这段代码:

<template>
  <div>
    <TheHeader @sidenavToggle="displaySidenav = !displaySideNav" />

    <Nuxt />

    <TheFooter />
  </div>
</template>

<script>
import TheHeader from '@/components/Navigation/TheHeader'
import TheFooter from '@/components/Navigation/TheFooter'

export default {
  components: {
    TheHeader,
    TheFooter
  }

}
</script>

从“@/components/Navigation/TheHeader”导入标题
从“@/components/Navigation/TheFooter”导入Footer
导出默认值{
组成部分:{
头,
门廊
}
}
我在AppButton.vue文件下也有此代码,该文件位于组件下:

<template>
  <button
    class="button"
    :class="btnStyle"
    v-bind="$attrs"
    v-on="$listeners">
    <slot />
  </button>
</template>

<script>

export default {
  name: 'AppButton',
  props: {
    btnStyle: {
      type: String,
      default: ''
    }
  }
}

</script>

导出默认值{
名称:“AppButton”,
道具:{
B风格:{
类型:字符串,
默认值:“”
}
}
}

错误状态为:“[Vue warn]:属性或方法“onSave”未在实例上定义,但在呈现过程中被引用。请通过初始化属性,确保此属性在数据选项中或对于基于类的组件是被动的。”我以前没有遇到过此问题,也不知道它现在出现的原因。Vue和nuxt.js中是否有更改?

您应该定义
onSave
方法

导出默认值{
组成部分:{
应用按钮
},
方法:{
onSave(){
//做点什么
}
}
}