首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >获取错误:错误:当我尝试单击要查看的注释时,_ctx.openNote不是一个函数

获取错误:错误:当我尝试单击要查看的注释时,_ctx.openNote不是一个函数
EN

Stack Overflow用户
提问于 2020-12-11 06:50:52
回答 1查看 282关注 0票数 1

我从头开始使用我的记事本应用程序,可以在这里找到:Issues with data bind in vue.js and events

问题是我似乎无法单击NoteList.vue中的备注来查看详细信息,我的绑定在某处断开了连接,事件处理程序似乎无法工作它在执行本机事件处理程序时抛出了一个未处理的错误: Vue warn: Unhandled error在

下面是我的代码:

App.vue

代码语言:javascript
复制
<template>
  <div class="body">
    <div class="notepad-container h-75 w-75">
      <header class="header d-flex justify-content-center align-items-center">
        <h4>Light Notepad v1</h4>
      </header>

      <section class="notepad-content">
        <note-list
          v-for="note in notes"
          :key="note.id"
          :note="note"
        ></note-list>
        <!-- <add-note-button></add-note-button> -->
      </section>

      <section class="notepad-editor">
        <!-- <save-button></save-button> -->
      </section>

      <section class="show-note"
      v-if="readingNote" === true">
        <show-note
          @open-note="readNote"
          v-for="note in notes"
          :key="note.id"
          :note="note"
        ></show-note>
      </section>
    </div>
  </div>
</template>
<script>
// import AddNoteButton from "./components/AddNoteButton.vue";
import NoteList from "./components/NoteList.vue";
// import SaveButton from "./components/SaveButton.vue";
import ShowNote from "./components/ShowNote.vue";

export default {
  components: {
    NoteList,
    // AddNoteButton,
    // SaveButton,
    ShowNote
  },
  data() {
    return {
      readingNote: false,
      notes: [
        {
          id: 1,
          title: "Note one title",
          body: "This is note ones body content"
        },
        {
          id: 2,
          title: "Note two title",
          body: "This is the second notes body content"
        }
      ],
      methods: {
        readNote() {
          this.readingNote = !this.readingNote;
        }
      }
    };
  },
};
</script>

NoteList.vue

代码语言:javascript
复制
<template>
  <div>
    <p @click="openNote">{{ note.title }}</p>
    <hr />
  </div>
</template>
<script>
export default {
  emits: ["open-note"],
  props: {
    note: {}
  },
  method: {
    openNote() {
      this.$emit("open-note");
      console.log("note opened!");
    }
  }
};
</script>

ShowNote.vue

代码语言:javascript
复制
<template>
  <div>note details: {{ note.body }}</div>
</template>

<script>
export default {
  props: {
    note: {}
  }
};
</script>
EN

Stack Overflow用户

回答已采纳

发布于 2020-12-11 07:57:11

我弄明白了,我有方法,而不是方法,我遗漏了方法中的's‘,现在我可以看到consol.log消息了,还在努力查看注释的细节。再近一步!

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65243420

复制
相关文章

相似问题

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